mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 23:34:42 +00:00
docs(guide/compiler): add fourth step on appending the compiled template to the DOM
Closes #5087
This commit is contained in:
parent
7ab73190b7
commit
e41e445b51
1 changed files with 5 additions and 1 deletions
|
|
@ -190,6 +190,7 @@ This should help give you an idea of what Angular does internally.
|
||||||
<pre>
|
<pre>
|
||||||
var $compile = ...; // injected into your code
|
var $compile = ...; // injected into your code
|
||||||
var scope = ...;
|
var scope = ...;
|
||||||
|
var parent = ...; // DOM element where the compiled template can be appended
|
||||||
|
|
||||||
var html = '<div ng-bind="exp"></div>';
|
var html = '<div ng-bind="exp"></div>';
|
||||||
|
|
||||||
|
|
@ -200,7 +201,10 @@ This should help give you an idea of what Angular does internally.
|
||||||
var linkFn = $compile(template);
|
var linkFn = $compile(template);
|
||||||
|
|
||||||
// Step 3: link the compiled template with the scope.
|
// Step 3: link the compiled template with the scope.
|
||||||
linkFn(scope);
|
var element = linkFn(scope);
|
||||||
|
|
||||||
|
// Step 4: Append to DOM (optional)
|
||||||
|
parent.appendChild(element);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### The difference between Compile and Link
|
### The difference between Compile and Link
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue