Friday, 29 May 2015

Angular const vs value


Angular $evalAsync vs $timeout

$evalAsync runs within the digest cycle, before the watchers are processed, so will be performed earlier than if you use $timeout.

$evalAsync from a directive, should run after the DOM has been manipulated by Angular but before the browser renders.

$evalAsync from a controller, should run before the DOM has been manipulated by Angular (and before the browser renders) -- rarely do you want this.

$timeout, should run after the DOM has been manipulated by Angular and after the browser renders (which may cause flicker in some cases).

Angular $eval vs $parse

Both evaluate Angular expressions, the difference is $eval returns a result whereas $parse returns a function.

AngularJS $watch() vs $watchCollection()

Live demo

Here is a comparison of the watch and watchCollection (default by ref) and watchCollection (by val equality). This code was based on a post from Ben Nadel's blog.


Angular with D3

Here is an example of using D3 inside an Angular application. Click here for live demo