English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-checked directive

AngularJS Reference Manual

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng}}-app="">
    <p>My cars:</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
    <p>Click "Check all" to select all cars.</p>
</body>
</html>
Test and see ‹/›

Definition and Usage

ng-checked The directive is used to set the checked attribute of checkboxes (checkboxes) or radio buttons (radio buttons).

If ng-checked If the attribute returns true, the checkbox (checkbox) or radio button (radio) will be selected.

Syntax

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

Input elements of type checkbox or radio support the type attribute.

Parameter Value

ValueDescription
expressionIf the expression returns true, the element option will be selected.

AngularJS Reference Manual