In practice, this means that the DOM manipulation done here will run once and always spread.
Run once?
This applies to the AngularJS compilation process. When the AngularJS compiler crosses the DOM, it compiles the directives that it finds exactly once.
DOM manipulation?
When the directive compilation function is called, it is possible to change the HTML before the AngularJS compiler.
Always distribute?
This means that the final DOM is determined at the end of the compilation process.
Example
To get to the point of the house, consider the following example:
<div directive1> <div directive2> <div directive3> </div> </div> </div>
The AngularJS compiler will first visit the progenitor, then the parent, and finally the child.
There are three ways to change HTML before compiling angular:
- directive 1 compilation function
- directive 2 compilation function
- directive 3 compilation function
Now let's see how the final HTML changes when we manipulate the DOM in the compilation function for directive 1:
When the directive1 compilation function is called:
<div directive1> <div directive2> <div directive3> </div> </div> </div>
In the compilation function, change the HTML before the AngularJS compiler:
app.directive('directive1', function() { restrict: 'A', compile: function($element, $attr) {
After calling the compilation function for directive 1:
<div directive1> <div directive4> </div> </div>
Pay attention to how the DOM changes, so directive 2 and directive 3 no longer exist, and directives 4 are next on the line for compilation.
prelinks offer slight performance improvements as they prevent the internal directives from starting the second digest cycle when the parent modifies the scope in prelink
Hm. It makes no sense to me. As I understand it, the digest phase occurs after the phases of the preliminary link and post link. I'm not sure how changing the scope in the phases of a prelink or post link will affect the digest cycle.
This image contains the following image: http://www.toptal.com/angular-js/angular-js-demystifying-directives
