angularjs ng-model-options directive
angularjs example
Bind the value of the input box to the scope variable when it loses focus:
<! 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 value of the input box to the scope variable when it loses focus:</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 value of the input box to the scope variable when it loses focus.</p>
</body>
</html>
Definition and usage
The ng-model-options directive binds html form elements to the scope variable
You can specify when the bound data is triggered,Or specify how many milliseconds to wait,Parameter setting can refer to the following description.
grammar
<element ng-model-options="option"</element>
<input> ;,<select> ;,<textarea> ;, the element supports the directive.
Parameter value
value | description |
---|---|
option | Specifies rules for binding data,The rules are as follows: {updateon:"event"} rules specify data to be bound after an event occurs {debounce:1000} specifies how many milliseconds to wait before binding data {allowinvalid:true | false} specifies whether to bind data after validation {gettersetter:true | false} specifies whether to bind to the model as getters/setters {timezone:"0100"} whether the rule uses a time zone |
Related articles
- angularjs select assignment ng-options configuration method
- How to set the default value of ng-options drop-down data in Angular
- Data binding method of ng-options in AngularJS to implement drop-down list
- How to use ng-options in angular instruction notes
- AngularJS ng-model instance code for dynamically binding ng-options
- Explain how to set the default value (initial value) when using angularjs's ng-options
- Ng-options directive for AngularJS study notes
- Method for setting data synchronization in ng-model-options in angularJs
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- javascript - how to check if an element exists in puppeteer
- xcode - pod install [!] no `podfile 'found in the project directory
- i want to call a child component method from a parent in vuejs
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning