mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-15 02:03:11 +00:00
docs(FormController): add methods for FormController
This commit is contained in:
parent
0cb87f91ae
commit
83f445336f
1 changed files with 42 additions and 1 deletions
|
|
@ -62,6 +62,16 @@ function FormController(element, attrs) {
|
||||||
addClass((isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey);
|
addClass((isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.directive:form.FormController#$addControl
|
||||||
|
* @methodOf ng.directive:form.FormController
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Register a control with the form.
|
||||||
|
*
|
||||||
|
* Input elements using ngModelController do this automatically when they are linked.
|
||||||
|
*/
|
||||||
form.$addControl = function(control) {
|
form.$addControl = function(control) {
|
||||||
controls.push(control);
|
controls.push(control);
|
||||||
|
|
||||||
|
|
@ -70,6 +80,16 @@ function FormController(element, attrs) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.directive:form.FormController#$removeControl
|
||||||
|
* @methodOf ng.directive:form.FormController
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Deregister a control from the form.
|
||||||
|
*
|
||||||
|
* Input elements using ngModelController do this automatically when they are destroyed.
|
||||||
|
*/
|
||||||
form.$removeControl = function(control) {
|
form.$removeControl = function(control) {
|
||||||
if (control.$name && form[control.$name] === control) {
|
if (control.$name && form[control.$name] === control) {
|
||||||
delete form[control.$name];
|
delete form[control.$name];
|
||||||
|
|
@ -81,6 +101,16 @@ function FormController(element, attrs) {
|
||||||
arrayRemove(controls, control);
|
arrayRemove(controls, control);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.directive:form.FormController#$setValidity
|
||||||
|
* @methodOf ng.directive:form.FormController
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Sets the validity of a form control.
|
||||||
|
*
|
||||||
|
* This method will also propagate to parent forms.
|
||||||
|
*/
|
||||||
form.$setValidity = function(validationToken, isValid, control) {
|
form.$setValidity = function(validationToken, isValid, control) {
|
||||||
var queue = errors[validationToken];
|
var queue = errors[validationToken];
|
||||||
|
|
||||||
|
|
@ -119,6 +149,17 @@ function FormController(element, attrs) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name ng.directive:form.FormController#$setDirty
|
||||||
|
* @methodOf ng.directive:form.FormController
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Sets the form to a dirty state.
|
||||||
|
*
|
||||||
|
* This method can be called to add the 'ng-dirty' class and set the form to a dirty
|
||||||
|
* state (ng-dirty class). This method will also propagate to parent forms.
|
||||||
|
*/
|
||||||
form.$setDirty = function() {
|
form.$setDirty = function() {
|
||||||
element.removeClass(PRISTINE_CLASS).addClass(DIRTY_CLASS);
|
element.removeClass(PRISTINE_CLASS).addClass(DIRTY_CLASS);
|
||||||
form.$dirty = true;
|
form.$dirty = true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue