Home>

angularjs ng-checked directive

angularjs example

Select one or all options:

<! Doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/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>

Definition and usage

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

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

grammar

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

<input>element support of type checkbox or radio.

Parameter value

value description
expression If true, the element option will be selected.

  • Previous Java Jersey framework first experience
  • Next Talking about object-oriented deep and shallow copy in JavaScript