簡介AngularJS的HTML DOM支持情況
以下指令可用于應(yīng)用程序數(shù)據(jù)綁定到HTML DOM元素的屬性。

添加ng-show屬性到一個HTML按鈕,并把它傳遞模型。綁定模型到復(fù)選框,看看以下變化。
<input type="checkbox" ng-model="showHide1">Show Button <button ng-show="showHide1">Click Me!</button>
ng-hide 指令
添加ng-hide屬性為HTML按鈕,通過它的模型。綁定模型到復(fù)選框,看看以下變化。
<input type="checkbox" ng-model="showHide2">Hide Button <button ng-hide="showHide2">Click Me!</button>
ng-click 指令
添加ng-click屬性為HTML按鈕并更新模型。模型綁定HTML看看結(jié)合的變化。
<p>Total click: {{ clickCounter }}</p></td>
<button ng-click="clickCounter = clickCounter + 1">Click Me!</button>
例子
下面的例子將展示上述所有指令。
testAngularJS.html
<html>
<head>
<title>AngularJS HTML DOM</title>
</head>
<body>
<h2>AngularJS Sample Application</h2>
<div ng-app="">
<table border="0">
<tr>
<td><input type="checkbox" ng-model="enableDisableButton">Disable Button</td>
<td><button ng-disabled="enableDisableButton">Click Me!</button></td>
</tr>
<tr>
<td><input type="checkbox" ng-model="showHide1">Show Button</td>
<td><button ng-show="showHide1">Click Me!</button></td>
</tr>
<tr>
<td><input type="checkbox" ng-model="showHide2">Hide Button</td>
<td><button ng-hide="showHide2">Click Me!</button></td>
</tr>
<tr>
<td><p>Total click: {{ clickCounter }}</p></td>
<td><button ng-click="clickCounter = clickCounter + 1">Click Me!</button></td>
</tr>
</table>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</body>
</html>
輸出
在Web瀏覽器打開textAngularJS.html,看到以下結(jié)果:

相關(guān)文章
解決Angularjs異步操作后臺請求用$q.all排列先后順序問題
解決Angularjs異步操作后臺請求用$q.all排列先后順序問題,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-11-11
快速解決angularJS中用post方法時后臺拿不到值的問題
今天小編就為大家分享一篇快速解決angularJS中用post方法時后臺拿不到值的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08
詳解關(guān)于Angular4 ng-zorro使用過程中遇到的問題
這篇文章主要介紹了詳解關(guān)于Angular4 ng-zorro使用過程中遇到的問題,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12
ANGULARJS中用NG-BIND指令實現(xiàn)單向綁定的例子
這篇文章主要介紹了ANGULARJS中用NG-BIND指令實現(xiàn)單向綁定的例子,本文簡單介紹AngularJS框架后,用一個實例演示{{}}插值法和ng-bind指令的使用,需要的朋友可以參考下2014-12-12

