mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
docs(ngModelController): improve $parsers/$formatters with example
This commit is contained in:
parent
6ca5272f94
commit
0cb87f91ae
1 changed files with 14 additions and 5 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue