Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6933fb7

Browse files
committed
docs(bootstrap): rewritten bootstrap guide
1 parent f5afcca commit 6933fb7

10 files changed

+114
-177
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ with the `$route` service
17581758
[angular.bootstrap]: http://docs-next.angularjs.org/api/angular.bootstrap
17591759
[$anchorScroll]: http://docs-next.angularjs.org/api/angular.module.ng.$anchorScroll
17601760
[$cacheFactory]: http://docs-next.angularjs.org/api/angular.module.ng.$cacheFactory
1761-
[bootstrapping]: http://docs-next.angularjs.org/guide/dev_guide.bootstrap
1761+
[bootstrapping]: http://docs-next.angularjs.org/guide/bootstrap
17621762
[angular.copy]: http://docs-next.angularjs.org/api/angular.copy
17631763
[ng:app]: http://docs-next.angularjs.org/api/angular.directive.ng-app
17641764
[$compile]: http://docs-next.angularjs.org/api/angular.module.ng.$compile

docs/content/cookbook/helloworld.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
Take a look through the source and note:
3030

31-
* The script tag that {@link guide/dev_guide.bootstrap bootstraps} the angular environment.
31+
* The script tag that {@link guide/bootstrap bootstraps} the angular environment.
3232
* The text {@link api/angular.module.ng.$compileProvider.directive.input input widget} which is
3333
bound to the greeting name text.
3434
* No need for listener registration and event firing on change events.

docs/content/guide/bootstrap.ngdoc

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
@ngdoc overview
2+
@name Developer Guide: Bootstrap
3+
@description
4+
5+
# Overview
6+
7+
This page explains the Angular initialization process and how you can manually initialize Angular
8+
if necessary.
9+
10+
11+
# Angular `<script>` Tag
12+
13+
This example shows the recommended path for integrating Angular with what we call automatic
14+
initialization.
15+
16+
17+
<pre>
18+
<!doctype html>
19+
<html xmlns:ng="http://angularjs.org" ng-app>
20+
<body>
21+
...
22+
<script src="angular.js">
23+
</body>
24+
</html>
25+
</pre>
26+
27+
* Place the `script` tag at the buttom of the page. Placing script tags at the end of the page
28+
impreves app load time becouse the HTML loading is not blocked by loading of the `angular.js`
29+
script. You can get the latest bits from {@link http://code.angularjs.org}. Please don't link
30+
your production code to this URL, as it will expose a security hole on your site. For
31+
experimental development linking to our site is fine.
32+
* Choose: `angular-[version].js` for a human-readable file, suitable for development and
33+
debugging.
34+
* Choose: `angular-[version].min.js` for a compressed and obfuscated file, suitable for use in
35+
production.
36+
* Place `ng-app` to the root of your application, typically on the `<html>` tag if you want
37+
anugular to auto-bootstrap your application.
38+
39+
<html ng-app>
40+
41+
* If you chose to use the old style directive syntax `ng:` then include xml-namespace in `html`
42+
to make IE happy. (This is here for historical resons, and we no longer recomend use of
43+
`ng:`.)
44+
45+
<html xmlns:ng="http://angularjs.org">
46+
47+
48+
49+
# Automatic Initialization
50+
51+
Angular initializes automatically upon `DOMContentLoaded` event, at which point angular looks for
52+
the {@link api/angular.module.ng.$compileProvider.directive.ng:app `ng-app`} directive which
53+
designates your application root. If {@link
54+
api/angular.module.ng.$compileProvider.directive.ng:app `ng-app`} directive is found then Angular
55+
will:
56+
57+
* load the {@link guide/module module} associated with the directive.
58+
* create the application {@link api/angular.module.AUTO.$injector injector}
59+
* compile the DOM treating the {@link api/angular.module.ng.$compileProvider.directive.ng:app
60+
`ng-app`} directive as the root of the compilation. This allows you to tell it to treat only a
61+
portion of the DOM as an Angular application.
62+
63+
64+
<pre>
65+
<!doctype html>
66+
<html ng-app="optionalModuleName">
67+
<body>
68+
I can add: {{ 1+2 }}.
69+
<script src="angular.js"></script>
70+
</body>
71+
</html>
72+
</pre>
73+
74+
75+
76+
# Manual Initialization
77+
78+
79+
If you need to have more control over the initialization process, you can use a manual
80+
bootstrapping method instead. Examples of when you'd need to do this include using script loaders
81+
or the need to perform an operation before the Angular compiles a page.
82+
83+
84+
Here is an example of manually initializing Angular. The example is equivalent to using the {@link
85+
api/angular.module.ng.$compileProvider.directive.ng:app ng:app} directive.
86+
87+
<pre>
88+
<!doctype html>
89+
<html xmlns:ng="http://angularjs.org">
90+
<body>
91+
Hello {{'World'}}!
92+
<script src="http://code.angularjs.org/angular.js"></script>
93+
<script>
94+
angular.element(document).ready(function() {
95+
angular.bootstrap(document);
96+
});
97+
</script>
98+
</body>
99+
</html>
100+
</pre>
101+
102+
This sequence that your code should follow:
103+
104+
1. After the page and all of the code is loaded, find the root of the HTML template, which is
105+
typically the root of the document.
106+
107+
2. Call {@link api/angular.bootstrap} to {@link compiler compile} the template into an
108+
executable, bi-directionally bound application.

docs/content/guide/dev_guide.bootstrap.auto_bootstrap.ngdoc

Lines changed: 0 additions & 54 deletions
This file was deleted.

docs/content/guide/dev_guide.bootstrap.manual_bootstrap.ngdoc

Lines changed: 0 additions & 49 deletions
This file was deleted.

docs/content/guide/dev_guide.bootstrap.ngdoc

Lines changed: 0 additions & 65 deletions
This file was deleted.

docs/content/guide/index.ngdoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ of the following documents before returning here to the Developer Guide:
1515

1616
## {@link dev_guide.overview Overview of Angular}
1717

18-
## {@link dev_guide.bootstrap Initializing Angular}
19-
20-
* {@link dev_guide.bootstrap.auto_bootstrap Understanding Automatic Initialization}
21-
* {@link dev_guide.bootstrap.manual_bootstrap Understanding Manual Initialization}
18+
## {@link bootstrap Initializing Angular}
2219

2320
## {@link dev_guide.mvc About MVC in Angular}
2421

docs/content/guide/overview.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ on.
113113

114114
In the `<html>` tag, we specify that it is an angular
115115
application with the `ng-app` directive. The `ng-app' will cause the angular to {@link
116-
dev_guide.bootstrap auto initialize} your application.
116+
bootstrap auto initialize} your application.
117117

118118
<html ng-app>
119119

docs/content/misc/started.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The next line downloads the angular script:
4040
</pre>
4141

4242
(For details on what happens when angular processes an HTML page,
43-
see {@link guide/dev_guide.bootstrap Bootstrap}.)
43+
see {@link guide/bootstrap Bootstrap}.)
4444

4545
Finally, this line in the `<body>` of the page is the template that describes
4646
how to display our greeting in the UI:

src/Angular.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ function angularInit(element, bootstrap) {
904904
* @description
905905
* Use this function to manually start up angular application.
906906
*
907-
* See: {@link guide/dev_guide.bootstrap.manual_bootstrap Bootstrap}
907+
* See: {@link guide/bootstrap Bootstrap}
908908
*
909909
* @param {Element} element DOM element which is the root of angular application.
910910
* @param {Array<String|Function>=} modules an array of module declarations. See: {@link angular.module modules}

0 commit comments

Comments
 (0)