AngularJS ng-model-options directive
AngularJS instance
Bind the value of the input box into the scope variable when the focus is lost:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body><div ng-app="myApp" ng-controller="myCtrl"><p>Update input box:</p><input ng-model="name" ng-model-options="{updateOn: 'blur'}"><p>Bind the input box value into the scope variable when the focus is lost:</p>{{name}}</div><script>var app = angular.module('myApp', []);app.controller('myCtrl', function($scope) { $scope.name = "John Doe";});</script><p>This example demonstrates how to use the ng-model-options directive to bind the input box's value into the scope variable when the focus is lost. </p></body></html>Definition and usage
The ng-model-options directive binds HTML form elements into scope variables
You can specify the time when the binding data is triggered, or specify how many milliseconds to wait. You can refer to the following instructions for setting the parameter.
grammar
<element ng-model-options="option"></element>
The <input>, <select>, <textarea>, elements support this directive.
Parameter value
| value | describe |
|---|---|
| option | Specifies the rules for binding data, the rules are as follows: {updateOn: 'event'} rule specifies that the data is bound after the event occurs {debounce: 1000} specifies how many milliseconds to wait before binding data {allowInvalid: true|false} Specifies whether the data needs to be bound after verification {getterSetter: true|false} Specifies whether to bind to the model as getters/setters {timezone: '0100'} Whether the rule uses time zone |
The above is the information sorting out the AngularJS ng-model-options directive, and the relevant information will be added in the future.