blob: 9f6464b26df6ff0d23766471ffe4a229cb229d12 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 | @ngdoc overview
@name  Developer Guide: Initializing Angular: Manual Initialization
@description
In the vast majority of cases you'll want to let Angular handle initialization automatically.  
If, however, you need to delay Angular from managing the page right after the DOMContentLoaded 
event fires, you'll need to control this initialization manually.
To initialize Angular -- after you've done your own special-purpose initialization -- just call 
the {@link api/angular.bootstrap bootstrap()} function with the HTML container node that you want
Angular to manage.  In automatic initialization you'd do this by adding the `ng-app` attribute to 
the same node.  Now, you won't use `ng-app` anywhere in your document.
To show the contrast of manual vs. automatic initialization, this automatic method:
<pre>
<!doctype html>
<html ng-app>
<head>
  <script src="http://code.angularjs.org/angular.js"></script>
...
</pre
is the same as this manual method:
<pre>
<!doctype html>
<html>
<head>
  <script src="http://code.angularjs.org/angular.js"></script>
  <script>
     angular.element(document).ready(function() {
       angular.bootstrap(document);
     });
  </script>
</head>
...
</pre>
## Related Topics
* {@link dev_guide.bootstrap Initializing Angular}
* {@link dev_guide.bootstrap.auto_bootstrap Automatic Initialization}
* {@link dev_guide.compiler Angular HTML compiler}
## Related API
{@link api/angular.module.ng.$compile Compiler API}
 |