@@ -15,13 +15,13 @@ var nullFormCtrl = {
15
15
*
16
16
* @property {boolean } $pristine True if user has not interacted with the form yet.
17
17
* @property {boolean } $dirty True if user has already interacted with the form.
18
- * @property {boolean } $valid True if all of the containg forms and controls are valid.
18
+ * @property {boolean } $valid True if all of the containing forms and controls are valid.
19
19
* @property {boolean } $invalid True if at least one containing control or form is invalid.
20
20
*
21
21
* @property {Object } $error Is an object hash, containing references to all invalid controls or
22
22
* forms, where:
23
23
*
24
- * - keys are validation tokens (error names) — such as `REQUIRED `, `URL ` or `EMAIL `),
24
+ * - keys are validation tokens (error names) — such as `required `, `url ` or `email `),
25
25
* - values are arrays of controls or forms that are invalid with given error.
26
26
*
27
27
* @description
@@ -119,6 +119,19 @@ function FormController(element, attrs) {
119
119
}
120
120
} ;
121
121
122
+ /**
123
+ * @ngdoc function
124
+ * @name ng.directive:form.FormController#$setDirty
125
+ * @methodOf ng.directive:form.FormController
126
+ *
127
+ * @description
128
+ * Sets the form as dirty. This will remove the 'ng-pristine' class and add 'ng-dirty' to
129
+ * the form element. This change will be propagated to all parent forms.
130
+ *
131
+ * Changes to an ng-model control within a form (e.g. {@link ng.directive:input input})
132
+ * automatically invoke this as part of
133
+ * {@link ng.directive:ngModel.NgModelController#$setViewValue $setViewValue()}.
134
+ */
122
135
form . $setDirty = function ( ) {
123
136
element . removeClass ( PRISTINE_CLASS ) . addClass ( DIRTY_CLASS ) ;
124
137
form . $dirty = true ;
@@ -162,7 +175,7 @@ function FormController(element, attrs) {
162
175
* does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a
163
176
* sub-group of controls needs to be determined.
164
177
*
165
- * @param {string= } ngForm| name Name of the form. If specified, the form controller will be published into
178
+ * @param {string= } name|ngForm Name of the form. If specified, the form controller will be published into
166
179
* related scope, under this name.
167
180
*
168
181
*/
@@ -235,12 +248,12 @@ function FormController(element, attrs) {
235
248
</script>
236
249
<form name="myForm" ng-controller="Ctrl">
237
250
userType: <input name="input" ng-model="userType" required>
238
- <span class="error" ng-show="myForm.input.$error.REQUIRED ">Required!</span><br>
251
+ <span class="error" ng-show="myForm.input.$error.required ">Required!</span><br>
239
252
<tt>userType = {{userType}}</tt><br>
240
253
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br>
241
254
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br>
242
255
<tt>myForm.$valid = {{myForm.$valid}}</tt><br>
243
- <tt>myForm.$error.REQUIRED = {{!!myForm.$error.REQUIRED }}</tt><br>
256
+ <tt>myForm.$error.required = {{!!myForm.$error.required }}</tt><br>
244
257
</form>
245
258
</doc:source>
246
259
<doc:scenario>
0 commit comments