O'Reilly logo

Mastering Web Application Development with AngularJS by Pawel Kozlowski, Peter Bacon Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Following the directive compilation life-cycle

When AngularJS compiles an HTML template it traverses the DOM supplied by the browser and tries to match each element, attribute, comment, and CSS class against its list of registered directives. When it matches a directive, AngularJS calls the directive's compile function, which returns a linking function. AngularJS collects all of these linking functions.

Note

The compilation stage is done before the scope has been prepared, and no scope data is available in the compile function.

Once all the directives have been compiled, AngularJS creates the scope and links each directive to the scope by calling each of the linking functions.

Note

At the linking stage, the scope is being attached to the directive, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required