aboutsummaryrefslogtreecommitdiffstats
path: root/src/Angular.js
diff options
context:
space:
mode:
authorMisko Hevery2010-08-14 10:29:50 -0700
committerMisko Hevery2010-08-14 10:29:50 -0700
commit26b5ae410970aab022452b5f0aa7f01a3963623a (patch)
treef66f6b34d6f1210fc07440b1206d86821914bdcd /src/Angular.js
parent14fe8cff2dc8225217de6b5bc553f93308f9490b (diff)
downloadangular.js-26b5ae410970aab022452b5f0aa7f01a3963623a.tar.bz2
fix __proto__ for ie.
Diffstat (limited to 'src/Angular.js')
0 files changed, 0 insertions, 0 deletions
ive it encounters. The compile function optionally returns a link function. This compilation process happens automatically when the page is loaded when you specify `ng:app` on the root element of the application. (See {@link dev_guide.bootstrap Initializing Angular}.) The compile and link functions are related as follows: * **compile function** — Registers a listener for the widget, directive, or markup expression. The compiler calls this function exactly once. * **link function** — Sets up the listener registered by the compile function. This function can be called multiple times, once per cloned DOM element. For example, in the case of the {@link api/angular.widget.@ng:repeat repeater widget} used in a list element (`<li ng:repeat="[item in dataset]"`), the link function gets called to set up a listener on each element in the list. Note that angular's built-in widgets, directives, and markup have predefined compile and link functions that you don't need to modify. When you create your own widgets, directives, or markup, you must write compile and link functions for them. Refer to the {@link api/angular.module.ng.$compile Compiler API} for details. When the angular compiler compiles a page, it proceeds through 3 phases: Compile, Create Root Scope, and Link: 1. Compile Phase 1. Recursively traverse the DOM, depth-first. 2. Look for a matching compile function of type widget, then markup, then directive. 3. If a compile function is found then execute it. 4. When the compile function completes, it should return a link function. Aggregate this link function with all link functions returned previously by step 3. 5. Repeat steps 3 and 4 for all compile functions found. The result of the compilation phase is an aggregate link function, which comprises all of the individual link functions. 2. Create Root Scope Phase * Inject all services into the root scope. 3. Link Phase 1. Execute the aggregate link function with the root scope. The aggregate link function calls all of the individual link functions that were generated in the compile phase. 2. If there are any clones of the DOM caused by repeating elements, call the link function multiple times, one for each repeating item. Note that while the compile function is executed exactly once, the link function can be executed multiple times, for example, once for each iteration in a repeater. The angular compiler exposes methods that you will need to make use of when writing your own widgets and directives. For information on these methods, see the {@link api/angular.module.ng.$compile Compiler API doc}. ## Related Topics * {@link dev_guide.compiler Angular HTML Compiler} * {@link dev_guide.compiler.extending_compiler Extending the Angular Compiler} * {@link dev_guide.compiler.testing_dom_element Testing a New DOM Element} ## Related API * {@link api/angular.module.ng.$compile $compile()}