AngularJS ng-checked 指令

AngularJS 參考手冊 AngularJS 參考手冊


AngularJS 實例

選擇一個或選擇所有選項:

<body ng-app="">
<p>My:</p>
<input type="checkbox" ng-model="all"> Check all<br><br>

<input type="checkbox" ng-checked="all">Volvo<br>
<input type="checkbox" ng-checked="all">Ford<br>
<input type="checkbox" ng-checked="all">Mercedes
</body>


定義和用法

ng-checked 指令用於設置複選框(checkbox)或單選按鈕(radio)的 checked 屬性。

如果 ng-checked 屬性返回 true,複選框(checkbox)或單選按鈕(radio)將會被選中。


語法

<input type="checkbox|radio" ng-checked="expression"></input>

type 為 checkbox 或 radio 的 <input> 元素支持。


參數值

描述
expression 如果返回 true,將會選中元素選項。

AngularJS 參考手冊 AngularJS 參考手冊