AngularJS ng-model-options directive
AngularJS instance
Bind the input box's value into the scope variable when the focus is lost:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/libs//1.4.6/"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <p>Update the input box:</p> <input ng-model="name" ng-model-options="{updateOn: 'blur'}"> <p>Bind the value of the input box when the focus is lost to scope In variables:</p> {{name}} </div> <script> var app = ('myApp', []); ('myCtrl', function($scope) { $ = "John Doe"; }); </script> <p>This example demonstrates how to use it ng-model-options The command binding inputs the value of the box when the focus is lost to scope In variables。</p> </body> </html>
Definition and usage
ng-model-optionsDirective binds HTML form elements into scope variable
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.