Reputation: 157
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
Upvotes: 1
Views: 640
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