mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
49 lines
1.4 KiB
Text
49 lines
1.4 KiB
Text
@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 `ngApp` attribute to
|
|
the same node. Now, you won't use `ngApp` 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}
|