I am binding the values of checkbox to an array and I need to implement a checkbox that selects all the other checkbox when checked. How can I implement the select All checkbox functionality in Angular material using its tag?
1
votes
1 Answers
0
votes
The easiest way is probably to react on the change of your "select all" checkbox with ng-change
and modify your array.
<md-checkbox ng-model="ctrl.allSelected" ng-change="ctrl.toggleSelection()" />
Iterate over the array manually or with lodash's _.forEach and set the value in your array.
function toggleSelection() {
_.forEach($scope.content, function (c) {
c.selected = $scope.allSelected;
});
}