AngularJS ng-checkedDirective

AngularJS 参考手册AngularJS Reference Manual


AngularJS Examples

Select one or select all options:

<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>

Try it Yourself »

Definition and Usage

ng-checkedThe directive is used to set the checked attribute of a checkbox or radio button.

Ifng-checkedthe expression returns true, the checkbox or radio button will be checked.


Syntax

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

Supported by <input> elements with type checkbox or radio.


Parameter Value

Value Description
expression If it returns true, the element option will be selected.

AngularJS 参考手册AngularJS Reference Manual

Other Extensions