How directive was compiled
HTML compilation takes place in three phases:
1. $compile traverse DOM node matching directives
If compiler finds directive,directive on the element it is added to the directives list of matching DOM elements, an element can have more than one directives
2. All directives that are bound to the DOM element once determined, compiler will sort the directives by priority
Each directive's compile function is executed. Each compile function has a chance to change the DOM. Each compile function returns the link function. These functions call the link function returned by each directive to form a combined link function
3. $compile link scope and template by calling the composite link function described in the previous step. Call Directives's link function in turn, configure the Register element for each directive to listen for events, and set the scope's $watch listener
var$compile = ...;//injected into your codevarScope = ...;varParent = ...;//DOM element where the compiled template can be appendedvarhtml = ' <div ng-bind= ' exp ' ></div> ';//Step 1:parse HTML into DOM elementvarTemplate =angular.element (HTML);//Step 2:compile the templatevarLINKFN =$compile (template);//Step 3:link The compiled template with the scope.varelement =LINKFN (scope);//Step 4:append to DOM (optional)Parent.appendchild (Element);
Angular $compiler