VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-checked-directive/

⇱ AngularJS ng-checked Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-checked Directive

Last Updated : 28 Jul, 2022

The ng-checked Directive in AngularJS is used to read the checked or unchecked state of the checkbox or radio button to true or false. If the expression inside the ng-checked attribute returns true then the checkbox/radio button will be checked otherwise it will be unchecked. 

Syntax:

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

If the expression returns true then the element's checked attribute will be checked. 

Example: This example uses the ng-checked Directive to select the checkbox and return the all selected checkbox value. 

Output:

👁 Image
 

Example: This example describes the ng-checked Directive to check & uncheck all at once.

Output:

👁 Image
 
Comment

Explore