欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

AngularJS基礎(chǔ) ng-model-options 指令簡單示例

 更新時間:2016年08月02日 10:25:38   投稿:lqh  
本文主要介紹AngularJS ng-model-options 指令,這里對ng-model-options指令的基本資料進(jìn)行整理,有需要的小伙伴可以參考下

AngularJS ng-model-options 指令

AngularJS 實(shí)例

在失去焦點(diǎn)時綁定輸入框的值到 scope 變量中:

<!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>更新輸入框:</p>
<input ng-model="name" ng-model-options="{updateOn: 'blur'}">

<p>在失去焦點(diǎn)時綁定輸入框的值到 scope 變量中:</p>

{{name}}

</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.name = "John Doe";
});
</script>

<p>該實(shí)例演示了如何使用 ng-model-options 指令綁定在失去焦點(diǎn)時輸入框的值到 scope 變量中。</p>

</body>
</html>

定義和用法

ng-model-options 指令綁定了 HTML 表單元素到 scope 變量中

你可以指定綁定數(shù)據(jù)觸發(fā)的時間,或者指定等待多少毫秒,參數(shù)設(shè)置可以參考以下說明。

語法

<element ng-model-options="option"></element>

<input>, <select>, <textarea>, 元素支持該指令。

參數(shù)值

描述
option 指定了綁定數(shù)據(jù)的規(guī)則,規(guī)則如下:

{updateOn: 'event'}規(guī)則指定事件發(fā)生后綁定數(shù)據(jù)

{debounce : 1000} 規(guī)定等待多少毫秒后綁定數(shù)據(jù)

{allowInvalid : true|false} 規(guī)定是否需要驗(yàn)證后綁定數(shù)據(jù)

{getterSetter : true|false} 規(guī)定是否作為 getters/setters 綁定到模型

{timezone : '0100'} 規(guī)則是否使用時區(qū)

以上就是對AngularJS ng-model-options 指令的資料整理,后續(xù)繼續(xù)補(bǔ)充相關(guān)資料。

相關(guān)文章

最新評論