Latest web development tutorials

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參考手冊