You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Angular to manage the DOM for your application, it needs to compile some or all of an HTML page. Angular does this initialization automatically when you load the angular.js script into your page and insert an `ng-app` directive (attribute) into one of the page's elements. For example, we can tell Angular to initialize the entire document:
5
+
For Angular to manage the DOM for your application, it needs to compile some or all of an HTML page. Angular does this initialization automatically when you load the angular.js script into your page and insert an `ngApp` directive (attribute) into one of the page's elements. For example, we can tell Angular to initialize the entire document:
6
6
7
7
<pre>
8
8
<!doctype html>
@@ -16,15 +16,15 @@ For Angular to manage the DOM for your application, it needs to compile some or
16
16
</html>
17
17
</pre>
18
18
19
-
You can also tell Angular to manage only a portion of a page. You would want to do this if you are using some other framework to manage other parts of the page. You do this by placing the `ng-app` directive on one or more container elements in the document. For example:
19
+
You can also tell Angular to manage only a portion of a page. You would want to do this if you are using some other framework to manage other parts of the page. You do this by placing the `ngApp` directive on one or more container elements in the document. For example:
20
20
21
21
<pre>
22
22
<div ng-app>
23
23
I can add: {{ 1+2 }}
24
24
</div>
25
25
</pre>
26
26
27
-
You can also ask `ng-app` to load additional {@link api/angular.module modules} containing services, directives or filers that you'll use on the page.
27
+
You can also ask `ngApp` to load additional {@link api/angular.module modules} containing services, directives or filers that you'll use on the page.
28
28
29
29
<pre>
30
30
<div ng-app="AwesomeModule">
@@ -38,7 +38,7 @@ From a high-level, here's what Angular does during the initialization process:
38
38
1. The browser loads the page, and then runs the Angular script. Angular then waits for the
39
39
`DOMContentLoaded` (or 'Load') event to attempt to initialize.
40
40
41
-
2. Angular looks for the `ng-app` directive. If found it compilies the DOM element containing `ng-app` and its children.
41
+
2. Angular looks for the `ngApp` directive. If found it compilies the DOM element containing `ngApp` and its children.
42
42
43
43
3. Angular creates a global variable `angular` and binds all Angular APIs to this object's fields.
Copy file name to clipboardExpand all lines: docs/content/guide/dev_guide.forms.ngdoc
+12-12
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,9 @@ Server-side validation is still necessary for a secure application.
12
12
13
13
14
14
# Simple form
15
-
The key directive in understanding two-way data-binding is {@link api/angular.module.ng.$compileProvider.directive.ng-model ng-model}.
16
-
The `ng-model` provides the two-way data-binding by synchronizing the model to the view, as well as view to the model.
17
-
In addition it provides {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController API} for other directives to augment its behavior.
15
+
The key directive in understanding two-way data-binding is {@link api/angular.module.ng.$compileProvider.directive.ngModel ngModel}.
16
+
The `ngModel` directive provides the two-way data-binding by synchronizing the model to the view, as well as view to the model.
17
+
In addition it provides {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController API} for other directives to augment its behavior.
18
18
19
19
<doc:example>
20
20
<doc:source>
@@ -56,7 +56,7 @@ Note that `novalidate` is used to disable browser's native form validation.
56
56
57
57
# Using CSS classes
58
58
59
-
To allow styling of form as well as controls, `ng-model` add these CSS classes:
59
+
To allow styling of form as well as controls, `ngModel` add these CSS classes:
60
60
61
61
- `ng-valid`
62
62
- `ng-invalid`
@@ -115,7 +115,7 @@ This ensures that the user is not distracted with an error until after interacti
115
115
116
116
A form is in instance of {@link api/angular.module.ng.$compileProvider.directive.form.FormController FormController}.
117
117
The form instance can optionally be published into the scope using the `name` attribute.
118
-
Similarly control is an instance of {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController NgModelController}.
118
+
Similarly control is an instance of {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController NgModelController}.
119
119
The control instance can similarly be published into the form instance using the `name` attribute.
120
120
This implies that the internal state of both the form and the control is available for binding in the view using the standard binding primitives.
121
121
@@ -181,16 +181,16 @@ This allows us to extend the above example with these features:
181
181
Angular provides basic implementation for most common html5 {@link api/angular.module.ng.$compileProvider.directive.input input}
182
182
types: ({@link api/angular.module.ng.$compileProvider.directive.input.text text}, {@link api/angular.module.ng.$compileProvider.directive.input.number number}, {@link api/angular.module.ng.$compileProvider.directive.input.url url}, {@link api/angular.module.ng.$compileProvider.directive.input.email email}, {@link api/angular.module.ng.$compileProvider.directive.input.radio radio}, {@link api/angular.module.ng.$compileProvider.directive.input.checkbox checkbox}), as well as some directives for validation (`required`, `pattern`, `minlength`, `maxlength`, `min`, `max`).
183
183
184
-
Defining your own validator can be done by defining your own directive which adds a custom validation function to the `ng-model` {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController controller}.
184
+
Defining your own validator can be done by defining your own directive which adds a custom validation function to the `ngModel` {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController controller}.
185
185
To get a hold of the controller the directive specifies a dependency as shown in the example below.
186
186
The validation can occur in two places:
187
187
188
188
* **Model to View update** -
189
-
Whenever the bound model changes, all functions in {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController#$formatters NgModelController#$formatters} array are pipe-lined, so that each of these functions has an opportunity to format the value and change validity state of the form control through {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController#$setValidity NgModelController#$setValidity}.
189
+
Whenever the bound model changes, all functions in {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController#$formatters NgModelController#$formatters} array are pipe-lined, so that each of these functions has an opportunity to format the value and change validity state of the form control through {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController#$setValidity NgModelController#$setValidity}.
190
190
191
191
* **View to Model update** -
192
-
In a similar way, whenever a user interacts with a control, the controll calls {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController#$setViewValue NgModelController#$setViewValue}.
193
-
This in turn pipelines all functions in {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController#$parsers NgModelController#$parsers} array, so that each of these functions has an opportunity to convert the value and change validity state of the form control through {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController#$setValidity NgModelController#$setValidity}.
192
+
In a similar way, whenever a user interacts with a control, the controll calls {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController#$setViewValue NgModelController#$setViewValue}.
193
+
This in turn pipelines all functions in {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController#$parsers NgModelController#$parsers} array, so that each of these functions has an opportunity to convert the value and change validity state of the form control through {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController#$setValidity NgModelController#$setValidity}.
194
194
195
195
In the following example we create two directives.
196
196
@@ -272,13 +272,13 @@ In the following example we create two directives.
272
272
</doc:example>
273
273
274
274
275
-
# Implementing custom form control (using ng-model)
275
+
# Implementing custom form control (using `ngModel`)
276
276
Angular implements all of the basic HTML form controls ({@link api/angular.module.ng.$compileProvider.directive.input input}, {@link api/angular.module.ng.$compileProvider.directive.select select}, {@link api/angular.module.ng.$compileProvider.directive.textarea textarea}), which should be sufficient for most cases.
277
277
However, if you need more flexibility, you can write your own form control as a directive.
278
278
279
-
In order for custom control to work with `ng-model` and to achieve two-way data-binding it needs to:
279
+
In order for custom control to work with `ngModel` and to achieve two-way data-binding it needs to:
280
280
281
-
- implement `render` method, which is responsible for rendering the data after it passed the {@link api/angular.module.ng.$compileProvider.directive.ng-model.NgModelController#$formatters NgModelController#$formatters},
281
+
- implement `render` method, which is responsible for rendering the data after it passed the {@link api/angular.module.ng.$compileProvider.directive.ngModel.NgModelController#$formatters NgModelController#$formatters},
282
282
- call `$setViewValue` method, whenever the user interacts with the control and model needs to be updated. This is usually done inside a DOM Event listener.
283
283
284
284
See {@link api/angular.module.ng.$compileProvider.directive $compileProvider.directive} for more info.
0 commit comments