select and deselect checkboxes with parent checkbox in angularjs

I want to select/deselect child check boxes based on parent check boxes i need this in angularjs anyone please give the solution

i want like this

enter image description here

Upvotes: 1

Views: 640

Answers (1)

Vipin Jain
Vipin Jain

Reputation: 3756

The ng-checked attribute in the checkbox takes in an expression. So you can give an expression with and/or conditions, as mentioned below to make it checked based on an expression.

<input type="checkbox" ng-checked="child_1 && child_2 && child_3 && child_4 && child_5" ng-model="parent"/> Select All<br/>

You dont have to write a seprate function to do the computation when every child checkbox is clicked.

In above example Child Check box model: child_1, child_2, child_3, child_4, child_5
Parent Check box model : parent
Example

Upvotes: 1

Related Questions