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

Thursday 12 February 2015

Angular Hyperlink directive

Here’s a simple example how to create your own hyperlink directive, demonstrating changing the DOM with directives.

Usage:

hyperlink-usage Directive: DOM: simple

Here's another example this time using an explicit call of the transclude function:

DOM: hyperlink

Here I’ve kept the hyperlink element in the DOM as this is considered a best practise by the Angular team since v1.3.