aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/form.js
diff options
context:
space:
mode:
authorDean Sofer2013-06-10 20:14:20 -0600
committerPete Bacon Darwin2013-06-12 21:46:31 +0100
commit83f445336f80a41f20a83f5b933fccd529cdc9a7 (patch)
treef3a3a5aac062288adb82c55d97dc77a5a839012e /src/ng/directive/form.js
parent0cb87f91ae8660016f9a79a62166ae03d0e7070d (diff)
downloadangular.js-83f445336f80a41f20a83f5b933fccd529cdc9a7.tar.bz2
docs(FormController): add methods for FormController
Diffstat (limited to 'src/ng/directive/form.js')
-rw-r--r--src/ng/directive/form.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js
index 36b775cb..ca055cb1 100644
--- a/src/ng/directive/form.js
+++ b/src/ng/directive/form.js
@@ -23,7 +23,7 @@ var nullFormCtrl = {
*
* - keys are validation tokens (error names) — such as `required`, `url` or `email`),
* - values are arrays of controls or forms that are invalid with given error.
- *
+ *
* @description
* `FormController` keeps track of all its controls and nested forms as well as state of them,
* such as being valid/invalid or dirty/pristine.
@@ -62,6 +62,16 @@ function FormController(element, attrs) {
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) {
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) {
if (control.$name && form[control.$name] === control) {
delete form[control.$name];
@@ -81,6 +101,16 @@ function FormController(element, attrs) {
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) {
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() {
element.removeClass(PRISTINE_CLASS).addClass(DIRTY_CLASS);
form.$dirty = true;