Skip to content

Commit 29274e1

Browse files
docs(ngApp): improve description and example
1 parent 23ba287 commit 29274e1

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

src/Angular.js

+28-16
Original file line numberDiff line numberDiff line change
@@ -1102,26 +1102,38 @@ function encodeUriQuery(val, pctEncodeSpaces) {
11021102
*
11031103
* @description
11041104
*
1105-
* Use this directive to auto-bootstrap an application. Only
1106-
* one ngApp directive can be used per HTML document. The directive
1107-
* designates the root of the application and is typically placed
1108-
* at the root of the page.
1105+
* Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive
1106+
* designates the **root element** of the application and is typically placed near the root element
1107+
* of the page - e.g. on the `<body>` or `<html>` tags.
11091108
*
1110-
* The first ngApp found in the document will be auto-bootstrapped. To use multiple applications in
1111-
* an HTML document you must manually bootstrap them using {@link angular.bootstrap}.
1112-
* Applications cannot be nested.
1109+
* Only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
1110+
* found in the document will be used to define the root element to auto-bootstrap as an
1111+
* application. To run multiple applications in an HTML document you must manually bootstrap them using
1112+
* {@link angular.bootstrap} instead. AngularJS applications cannot be nested within each other.
11131113
*
1114-
* In the example below if the `ngApp` directive were not placed
1115-
* on the `html` element then the document would not be compiled
1116-
* and the `{{ 1+2 }}` would not be resolved to `3`.
1114+
* You can specify an **AngularJS module** to be used as the root module for the application. This
1115+
* module will be loaded into the {@link AUTO.$injector} when the application is bootstrapped and
1116+
* should contain the application code needed or have dependencies on other modules that will
1117+
* contain the code. See {@link angular.module} for more information.
11171118
*
1118-
* `ngApp` is the easiest way to bootstrap an application.
1119+
* In the example below if the `ngApp` directive were not placed on the `html` element then the
1120+
* document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`
1121+
* would not be resolved to `3`.
11191122
*
1120-
<doc:example>
1121-
<doc:source>
1122-
I can add: 1 + 2 = {{ 1+2 }}
1123-
</doc:source>
1124-
</doc:example>
1123+
* `ngApp` is the easiest, and most common, way to bootstrap an application.
1124+
*
1125+
<example module="ngAppDemo">
1126+
<file name="index.html">
1127+
<div ng-controller="ngAppDemoController">
1128+
I can add: {{a}} + {{b}} = {{ a+b }}
1129+
</file>
1130+
<file name="script.js">
1131+
angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {
1132+
$scope.a = 1;
1133+
$scope.b = 2;
1134+
});
1135+
</file>
1136+
</example>
11251137
*
11261138
*/
11271139
function angularInit(element, bootstrap) {

0 commit comments

Comments
 (0)