mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-05 21:54:42 +00:00
docs(*): fixing various docs
This commit is contained in:
parent
8b8fdddc0b
commit
716b5fd3e2
10 changed files with 34 additions and 32 deletions
|
|
@ -12,7 +12,7 @@ explicitly.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html xmlns:ng="http://angularjs.org">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="http://code.angularjs.org/angular.js"></script>
|
<script src="http://code.angularjs.org/angular.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ and manage the whole page. You do this as follows:
|
||||||
|
|
||||||
<html xmlns:ng="http://angularjs.org">
|
<html xmlns:ng="http://angularjs.org">
|
||||||
|
|
||||||
You need to declare the angular namespace declaration in the following cases:
|
You need to add the angular namespace declaration if you use `ng:something` style of declaring
|
||||||
|
angular directives and you write your templates as XHTML. Or when you are targeting Internet
|
||||||
* For all types of browser if you are using XHTML.
|
Explorer older than version 9 (because older versions of IE do not render namespace
|
||||||
* For Internet Explorer older than version 9 (because older versions of IE do not render namespace
|
properly for either HTML or XHTML). For more info please read {@link ie Internet Explorer
|
||||||
properly for either HTML or XHTML).
|
Compatibility} doc.
|
||||||
|
|
||||||
|
|
||||||
## Creating Your Own Namespaces
|
## Creating Your Own Namespaces
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ controller from the HTML template, as follows:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html xmlns:ng="http://angularjs.org" ng-controller="MyController" ng-app>
|
<html ng-controller="MyController" ng-app>
|
||||||
<script src="http://code.angularjs.org/angular.min.js"></script>
|
<script src="http://code.angularjs.org/angular.min.js"></script>
|
||||||
<body>
|
<body>
|
||||||
...
|
...
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,10 @@ objects with additional behavior. By prefixing its additions with $ we are reser
|
||||||
so that angular developers and developers who use angular can develop in harmony without collisions.
|
so that angular developers and developers who use angular can develop in harmony without collisions.
|
||||||
|
|
||||||
|
|
||||||
|
## Related Topics
|
||||||
|
|
||||||
|
* {@link dev_guide.templates.filters Understanding Angular Filters}
|
||||||
|
|
||||||
## Related API
|
## Related API
|
||||||
|
|
||||||
* {@link api/angular.module.ng.$compile Angular Compiler API}
|
* {@link api/angular.module.ng.$compile Angular Compiler API}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ http://docs.angularjs.org/#!/api/angular.module.ng.$filter.number number} and {@
|
||||||
http://docs.angularjs.org/#!/api/angular.module.ng.$filter.currency currency} filters.
|
http://docs.angularjs.org/#!/api/angular.module.ng.$filter.currency currency} filters.
|
||||||
|
|
||||||
Additionally, Angular supports localizable pluralization support provided by the {@link
|
Additionally, Angular supports localizable pluralization support provided by the {@link
|
||||||
api/angular.module.ng.$compileProvider.directive.ng-pluralize ng-pluralize widget}.
|
api/angular.module.ng.$compileProvider.directive.ng-pluralize ng-pluralize directive}.
|
||||||
|
|
||||||
All localizable Angular components depend on locale-specific rule sets managed by the {@link
|
All localizable Angular components depend on locale-specific rule sets managed by the {@link
|
||||||
api/angular.module.ng.$locale $locale service}.
|
api/angular.module.ng.$locale $locale service}.
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ Do not use controllers for:
|
||||||
manipulation—the presentation logic of an application—is well known for being hard to test.
|
manipulation—the presentation logic of an application—is well known for being hard to test.
|
||||||
Putting any presentation logic into controllers significantly affects testability of the business
|
Putting any presentation logic into controllers significantly affects testability of the business
|
||||||
logic. Angular offers {@link dev_guide.templates.databinding} for automatic DOM manipulation. If
|
logic. Angular offers {@link dev_guide.templates.databinding} for automatic DOM manipulation. If
|
||||||
you have to perform your own manual DOM manipulation, encapsulate the presentation logic in and
|
you have to perform your own manual DOM manipulation, encapsulate the presentation logic in
|
||||||
{@link api/angular.module.ng.$compileProvider.directive directives}.
|
{@link api/angular.module.ng.$compileProvider.directive directives}.
|
||||||
- Input formatting — Use {@link dev_guide.forms angular form widgets} instead.
|
- Input formatting — Use {@link dev_guide.forms angular form controls} instead.
|
||||||
- Output filtering — Use {@link dev_guide.templates.filters angular filters} instead.
|
- Output filtering — Use {@link dev_guide.templates.filters angular filters} instead.
|
||||||
- Run stateless or stateful code shared across controllers — Use {@link dev_guide.services angular
|
- Run stateless or stateful code shared across controllers — Use {@link dev_guide.services angular
|
||||||
services} instead.
|
services} instead.
|
||||||
|
|
|
||||||
|
|
@ -79,12 +79,10 @@ easier a web developer's life can if they're using angular:
|
||||||
Try out the Live Preview above, and then let's walk through the example and describe what's going
|
Try out the Live Preview above, and then let's walk through the example and describe what's going
|
||||||
on.
|
on.
|
||||||
|
|
||||||
In the `<html>` tag, we add an attribute to let the browser know about the angular namespace.
|
In the `<html>` tag we specify that this is an angular application with the `ng-app` directive.
|
||||||
This ensures angular runs nicely in all major browsers. We also specify that it is an angular
|
The `ng-app' will cause the angular to {@link dev_guide.bootstrap auto initialize} your application.
|
||||||
application with the `ng-app` directive. The `ng-app' will cause the angular to {@link
|
|
||||||
dev_guide.bootstrap auto initialize} your application.
|
|
||||||
|
|
||||||
<html ng-ng-app>
|
<html ng-app>
|
||||||
|
|
||||||
We load the angular using the `<script>` tag:
|
We load the angular using the `<script>` tag:
|
||||||
|
|
||||||
|
|
@ -111,12 +109,12 @@ And finally, the mysterious `{{ double curly braces }}`:
|
||||||
|
|
||||||
Total: {{qty * cost | currency}}
|
Total: {{qty * cost | currency}}
|
||||||
|
|
||||||
This notation, `{{ _expression_ }}`, is a bit of built-in angular {@link http://localhost:8000/build/docs/api/angular.module.ng.$interpolate
|
This notation, `{{ _expression_ }}`, is a bit of built-in angular binding markup, a shortcut for
|
||||||
markup}, a shortcut for displaying data to the user. The expression within curly braces gets
|
displaying data to the user. The expression within curly braces is monitored and its evaluated value
|
||||||
transformed by the angular compiler into an angular directive ({@link api/angular.module.ng.$compileProvider.directive.ng-bind
|
is updated into the view by angular's template compiler. Alternatively, one could use angular's
|
||||||
ng-bind}). The expression itself can be a combination of both an expression and a {@link
|
{@link api/angular.module.ng.$compileProvider.directive.ng-bind ng-bind}) directive. The expression
|
||||||
dev_guide.templates.filters filter}: `{{ expression | filter }}`. Angular provides filters for
|
itself can be a combination of both an expression and a {@link dev_guide.templates.filters filter}:
|
||||||
formatting display data.
|
`{{ expression | filter }}`. Angular provides filters for formatting display data.
|
||||||
|
|
||||||
In the example above, the expression in double-curly braces directs angular to, "Bind the data we
|
In the example above, the expression in double-curly braces directs angular to, "Bind the data we
|
||||||
got from the input widgets to the display, multiply them together, and format the resulting number
|
got from the input widgets to the display, multiply them together, and format the resulting number
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ the dynamic view DOM.
|
||||||
|
|
||||||
These are the types of angular elements and element attributes you can use in a template:
|
These are the types of angular elements and element attributes you can use in a template:
|
||||||
|
|
||||||
* {@link api/angular.module.ng.$compileProvider.directive Directive} — An attribute that augments an existing DOM
|
* {@link api/angular.module.ng.$compileProvider.directive Directive} — An attribute or element that
|
||||||
element.
|
augments an existing DOM element or represents a reusable DOM component - a widget.
|
||||||
* {@link api/angular.module.ng.$interpolate Markup} — The double
|
* {@link api/angular.module.ng.$interpolate Markup} — The double
|
||||||
curly brace notation `{{ }}` to bind expressions to elements is built-in angular markup.
|
curly brace notation `{{ }}` to bind expressions to elements is built-in angular markup.
|
||||||
* {@link dev_guide.templates.filters Filter} — Formats your data for display to the user.
|
* {@link dev_guide.templates.filters Filter} — Formats your data for display to the user.
|
||||||
|
|
@ -21,7 +21,8 @@ Note: In addition to declaring the elements above in templates, you can also ac
|
||||||
in JavaScript code.
|
in JavaScript code.
|
||||||
|
|
||||||
The following code snippet shows a simple angular template made up of standard HTML tags along with
|
The following code snippet shows a simple angular template made up of standard HTML tags along with
|
||||||
angular {@link api/angular.module.ng.$compileProvider.directive directives} and {@link dev_guide.expressions expressions}:
|
angular {@link api/angular.module.ng.$compileProvider.directive directives} and curly-brace bindings
|
||||||
|
with {@link dev_guide.expressions expressions}:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<html ng-app>
|
<html ng-app>
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ development.
|
||||||
production.
|
production.
|
||||||
|
|
||||||
To point your code to an angular script on the angular server, use the following template. This
|
To point your code to an angular script on the angular server, use the following template. This
|
||||||
example points to (non-minified) version 0.9.12:
|
example points to (non-minified) version 0.10.6:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html xmlns:ng="http://angularjs.org" ng-app>
|
<html ng-app>
|
||||||
<head>
|
<head>
|
||||||
<title>My Angular App</title>
|
<title>My Angular App</title>
|
||||||
<script src="http://code.angularjs.org/angular-0.9.12.js"></script>
|
<script src="http://code.angularjs.org/angular-0.10.6.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,13 @@ A great way for you to get started with AngularJS is to create the tradtional
|
||||||
|
|
||||||
The resulting web page should look something like the following:
|
The resulting web page should look something like the following:
|
||||||
|
|
||||||
<img class="center" src="img/helloworld.png" border="1" />
|
<img class="center" src="img/helloworld.png" border="1">
|
||||||
|
|
||||||
Now let's take a closer look at that code, and see what is going on behind
|
Now let's take a closer look at that code, and see what is going on behind
|
||||||
the scenes.
|
the scenes.
|
||||||
|
|
||||||
The first line of interest defines the `ng` namespace, which makes
|
The `ng-app` tags tells angular to process the entire HTML page and bootstrap the app when the page
|
||||||
AngularJS work across all browsers (especially important for IE). The
|
is loaded:
|
||||||
`ng-app` tags tells angular to process the entire HTML when it is loaded:
|
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<html ng-app>
|
<html ng-app>
|
||||||
|
|
@ -37,7 +36,7 @@ AngularJS work across all browsers (especially important for IE). The
|
||||||
The next line downloads the angular script:
|
The next line downloads the angular script:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<script type="text/javascript" src="http://code.angularjs.org/angular-?.?.?.min.js"></script>
|
<script src="http://code.angularjs.org/angular-?.?.?.min.js"></script>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
(For details on what happens when angular processes an HTML page,
|
(For details on what happens when angular processes an HTML page,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue