Angular 1.3 provides us with some improvements over an already very decent framework. At ngEurope, the sessions were fast and intensive, which was an interesting approach, but also didn’t allow for very many details. That being said, here are the points I noted.

$compileProvider.debugInfoEnabled(false);

This allows you to disable all the debugging info for the code you will deploy in production. Read more about it in the docs.

$httpProvider.useApplyAsync(true)

Normally, returning from an HTTP call will trigger Angular’s $apply function. If you are doing several HTTP calls in succession, it might be interesting to only call the $apply function when they have finished. The useApplyAsync function gives you that possibility. Setting this to true will make Angular wait for HTTP calls that finish close together to finish, before calling $apply.

one-time binding (with ::)

Finally! One-time bindings allow you to make Angular forget about the binding once it has rendered it. This can improve performance, especially when you have a lot of bindings that no longer change once the result of the binding was rendered. Doing so is easy: just prefix your binding with ‘::’, like so:

<span>{{::user.name}}</span>

Now, Angular will no longer track changes to this property

ng-model-options="{debounce: 500}

This waits 500ms before updating the binding. This can be useful when the updating of your binding could take a while.

ng-model-options="{updateOn: 'blur'}

If you’ve used WPF, this is the equivalent of UpdateSourceTrigger. The updateOn option accepts any javascript event and does just that: it updates the model when the given event is raised.

allOrNothing

The allOrNothing feature prevents Angular from making an HTTP request when it doesn’t make any sense. For example this:

ng-src="users/{user.id}/avatar.png"

will not make an HTTP request if user or user.id is undefined.

Finally, ngMessages allows for easier validation messages.

So that is what I learnt from the session about Angular 1.3. It’s just a quick overview, but it’s good to know what’s possible. When you’re facing a particular situation, and you know Angular has a solution for it, you won’t feel the need to implement a solution yourself. You can just go check out the documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.