Detailed explanation of ng checked instructions in AngularJS introductory tutorial

  • 2021-07-06 09:56:47
  • OfStack

AngularJS ng-checked Directive

AngularJS instance

Select 1 or select 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"  Choose all the cars. </p>
</body>
</html>

Definition and usage

The ng-checked directives are used to set the checked property of a check box (checkbox) or radio button (radio).

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

Grammar

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

type is checkbox or radio < input > Element support.

Parameter value

描述
expression 如果返回 true,将会选中元素选项。

The above is the data collation of AngularJS ng-checked instructions, and the follow-up will continue to be supplemented. Thank you for your support!


Related articles: