diff options
| author | Pawel Kozlowski | 2012-07-07 19:02:04 +0200 |
|---|---|---|
| committer | Igor Minar | 2012-11-26 16:44:34 +0100 |
| commit | 733a97adf87bf8f7ec6be22b37c4676cf7b5fc2b (patch) | |
| tree | 99422e0e402fe4b4340552f8f80a4feb3ac861f0 /src/ng/directive/input.js | |
| parent | 96ed9ff59a454486c88bdf92ad9d28ab8864b85e (diff) | |
| download | angular.js-733a97adf87bf8f7ec6be22b37c4676cf7b5fc2b.tar.bz2 | |
feat(form): add ability to reset a form to pristine state
Retting a form to pristine state will cause all of the nested
form and form controls to be recursively reset as well.
Closes #856
Diffstat (limited to 'src/ng/directive/input.js')
| -rw-r--r-- | src/ng/directive/input.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index e17c12b3..695ca88a 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -978,6 +978,22 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$ parentForm.$setValidity(validationErrorKey, isValid, this); }; + /** + * @ngdoc function + * @name ng.directive:ngModel.NgModelController#$setPristine + * @methodOf ng.directive:ngModel.NgModelController + * + * @description + * Sets the control to its pristine state. + * + * This method can be called to remove the 'ng-dirty' class and set the control to its pristine + * state (ng-pristine class). + */ + this.$setPristine = function () { + this.$dirty = false; + this.$pristine = true; + $element.removeClass(DIRTY_CLASS).addClass(PRISTINE_CLASS); + }; /** * @ngdoc function |
