O'Reilly logo

AngularJS Directives by Alex Vanston

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

Chapter 4. Compile versus Link

Within Angular directives, there are two primary phases that handle the process of connecting the directive logic to the DOM, as well as performing any necessary DOM manipulation. The first phase is the compile phase, which works on the element before it's been inserted into the document, and thus is great for performance, but can't be used to attach any DOM related plugins since the element isn't accessible yet. The second phase is the linking phase, which works on the element after it has been inserted into the DOM and has the appropriate scope instance created and initialized for it. For this chapter, we'll start by reviewing a couple directives built into Angular as an example of why this separation exists ...

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