AngularJS ng-model-options 指令
AngularJS 教程
· 2019-04-01 20:37:12
实例
在失去焦点时绑定输入框的值到 scope 变量中:
<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 = "John Doe";
});
</script>
<input ng-model="name" ng-model-options="{updateOn: 'blur'}">
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name = "John Doe";
});
</script>
定义和用法
ng-model-options 指令绑定了 HTML 表单元素到 scope 变量中
你可以指定绑定数据触发的时间,或者指定等待多少毫秒,参数设置可以参考以下说明。
语法
<element ng-model-options="option"></element>
<input>, <select>, <textarea>, 元素支持该指令。
参数值
| 值 | 描述 |
|---|---|
| option | 指定了绑定数据的规则,规则如下: {updateOn: 'event'}规则指定事件发生后绑定数据 {debounce : 1000} 规定等待多少毫秒后绑定数据 {allowInvalid : true|false} 规定是否需要验证后绑定数据 {getterSetter : true|false} 规定是否作为 getters/setters 绑定到模型 {timezone : '0100'} 规则是否使用时区 |
点击查看所有 AngularJS 教程 文章: https://codercto.com/courses/l/36.html
The Web Designer's Idea Book, Vol. 2
Patrick McNeil / How / 2010-9-19 / USD 30.00
Web Design Inspiration at a Glance Volume 2 of The Web Designer's Idea Book includes more than 650 new websites arranged thematically, so you can easily find inspiration for your work. Auth......一起来看看 《The Web Designer's Idea Book, Vol. 2》 这本书的介绍吧!