AngularJS ng-model-options Instruction
Definition and Usage
ng-model-options
Instructions are used to control the binding of HTML form elements and variables in the scope.
You can specify that the binding should wait for a specific event to occur, or wait for a specific number of milliseconds, etc. For more information, please refer to the valid values listed in the following parameter values.
Example
Wait for the field to lose focus before binding data:
<div ng-app="myApp" ng-controller="myCtrl"> <input ng-model="name" ng-model-options="{updateOn: 'blur'}"> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.name = "Bill Gates"; ); </script>
Syntax
<element ng-model-options="Option</element>
Supported by <input>
、<select>
and <textarea>
Element Support.
Parameters
Parameters | Description |
---|---|
Option |
An object specifying the options that the data binding must follow. Valid objects include: {updateOn: 'event'} Specifies when the binding should occur when a specific event occurs. {debounce : 1000} Specifies how many milliseconds the binding should wait. {allowInvalid : true|false} Specifies whether binding can be performed if the value does not pass validation. {getterSetter : true|false} Specifies whether the functions bound to the model should be considered as getter/setter. {timezone : '0100'} Specifies which timezone should be used when processing Date objects. |