mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
docs(ngApp): improve description and example
This commit is contained in:
parent
23ba287897
commit
29274e1d8d
1 changed files with 28 additions and 16 deletions
|
|
@ -1102,26 +1102,38 @@ function encodeUriQuery(val, pctEncodeSpaces) {
|
|||
*
|
||||
* @description
|
||||
*
|
||||
* Use this directive to auto-bootstrap an application. Only
|
||||
* one ngApp directive can be used per HTML document. The directive
|
||||
* designates the root of the application and is typically placed
|
||||
* at the root of the page.
|
||||
* Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive
|
||||
* designates the **root element** of the application and is typically placed near the root element
|
||||
* of the page - e.g. on the `<body>` or `<html>` tags.
|
||||
*
|
||||
* The first ngApp found in the document will be auto-bootstrapped. To use multiple applications in
|
||||
* an HTML document you must manually bootstrap them using {@link angular.bootstrap}.
|
||||
* Applications cannot be nested.
|
||||
* Only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
|
||||
* found in the document will be used to define the root element to auto-bootstrap as an
|
||||
* application. To run multiple applications in an HTML document you must manually bootstrap them using
|
||||
* {@link angular.bootstrap} instead. AngularJS applications cannot be nested within each other.
|
||||
*
|
||||
* In the example below if the `ngApp` directive were not placed
|
||||
* on the `html` element then the document would not be compiled
|
||||
* and the `{{ 1+2 }}` would not be resolved to `3`.
|
||||
* You can specify an **AngularJS module** to be used as the root module for the application. This
|
||||
* module will be loaded into the {@link AUTO.$injector} when the application is bootstrapped and
|
||||
* should contain the application code needed or have dependencies on other modules that will
|
||||
* contain the code. See {@link angular.module} for more information.
|
||||
*
|
||||
* `ngApp` is the easiest way to bootstrap an application.
|
||||
* In the example below if the `ngApp` directive were not placed on the `html` element then the
|
||||
* document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`
|
||||
* would not be resolved to `3`.
|
||||
*
|
||||
<doc:example>
|
||||
<doc:source>
|
||||
I can add: 1 + 2 = {{ 1+2 }}
|
||||
</doc:source>
|
||||
</doc:example>
|
||||
* `ngApp` is the easiest, and most common, way to bootstrap an application.
|
||||
*
|
||||
<example module="ngAppDemo">
|
||||
<file name="index.html">
|
||||
<div ng-controller="ngAppDemoController">
|
||||
I can add: {{a}} + {{b}} = {{ a+b }}
|
||||
</file>
|
||||
<file name="script.js">
|
||||
angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {
|
||||
$scope.a = 1;
|
||||
$scope.b = 2;
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*
|
||||
*/
|
||||
function angularInit(element, bootstrap) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue