diff options
Diffstat (limited to 'docs/content/guide/bootstrap.ngdoc')
| -rw-r--r-- | docs/content/guide/bootstrap.ngdoc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/docs/content/guide/bootstrap.ngdoc b/docs/content/guide/bootstrap.ngdoc index 3983f7b5..ef384168 100644 --- a/docs/content/guide/bootstrap.ngdoc +++ b/docs/content/guide/bootstrap.ngdoc @@ -7,8 +7,7 @@ This page explains the Angular initialization process and how you can manually initialize Angular if necessary. - -# Angular `<script>` Tag +## Angular `<script>` Tag This example shows the recommended path for integrating Angular with what we call automatic initialization. @@ -50,7 +49,7 @@ initialization. -# Automatic Initialization +## Automatic Initialization Angular initializes automatically upon `DOMContentLoaded` event or when the `angular.js` script is evaluated if at that time `document.readyState` is set to `'complete'`. At this point Angular looks @@ -76,16 +75,14 @@ If the {@link api/ng.directive:ngApp `ng-app`} directive is found then Angular w -# Manual Initialization +## Manual Initialization If you need to have more control over the initialization process, you can use a manual bootstrapping method instead. Examples of when you'd need to do this include using script loaders or the need to perform an operation before Angular compiles a page. - -Here is an example of manually initializing Angular. The example is equivalent to using the {@link -api/ng.directive:ngApp ng-app} directive. +Here is an example of manually initializing Angular: <pre> <!doctype html> @@ -95,17 +92,22 @@ api/ng.directive:ngApp ng-app} directive. <script src="http://code.angularjs.org/angular.js"></script> <script> angular.element(document).ready(function() { - angular.bootstrap(document); + angular.bootstrap(document, ['optionalModuleName']); }); </script> </body> </html> </pre> +Note that we have provided the name of our application module to be loaded into the injector as the second +parameter of the {@link api/angular.bootstrap} function. This example is equivalent to using the +{@link api/ng.directive:ngApp ng-app} directive, with `ng-app="optionalModuleName"`, as in the automatic +initialization example above. + This is the sequence that your code should follow: - 1. After the page and all of the code is loaded, find the root of the HTML template, which is - typically the root of the document. + 1. After the page and all of the code is loaded, find the root element of your AngularJS + application, which is typically the root of the document. - 2. Call {@link api/angular.bootstrap} to {@link compiler compile} the template into an + 2. Call {@link api/angular.bootstrap} to {@link compiler compile} the element into an executable, bi-directionally bound application. |
