diff options
| author | Dean Peterson | 2013-06-12 21:17:29 +0100 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-06-12 21:17:42 +0100 |
| commit | 0cb87f91ae8660016f9a79a62166ae03d0e7070d (patch) | |
| tree | a45a4d5123b98040160b29b34e5f65076ab25051 /src/ng/directive/input.js | |
| parent | 6ca5272f94f095b864682f438e4cd916aae073ad (diff) | |
| download | angular.js-0cb87f91ae8660016f9a79a62166ae03d0e7070d.tar.bz2 | |
docs(ngModelController): improve $parsers/$formatters with example
Diffstat (limited to 'src/ng/directive/input.js')
| -rw-r--r-- | src/ng/directive/input.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index fd301c6a..591da99e 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -813,12 +813,21 @@ var VALID_CLASS = 'ng-valid', * * @property {string} $viewValue Actual string value in the view. * @property {*} $modelValue The value in the model, that the control is bound to. - * @property {Array.<Function>} $parsers Whenever the control reads value from the DOM, it executes - * all of these functions to sanitize / convert the value as well as validate. - * - * @property {Array.<Function>} $formatters Whenever the model value changes, it executes all of - * these functions to convert the value as well as validate. + * @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever + the control reads value from the DOM. Each function is called, in turn, passing the value + through to the next. Used to sanitize / convert the value as well as validation. * + * @property {Array.<Function>} $formatters Array of functions to execute, as a pipeline, whenever + the model value changes. Each function is called, in turn, passing the value through to the + next. Used to format / convert values for display in the control and validation. + * <pre> + * function formatter(value) { + * if (value) { + * return value.toUpperCase(); + * } + * } + * ngModel.$formatters.push(formatter); + * </pre> * @property {Object} $error An object hash with all errors as keys. * * @property {boolean} $pristine True if user has not interacted with the control yet. |
