I am using an ng-repeat to display items from a JSON file, and they can be filtered based on user input.
<tr ng-repeat="i in filteredItems = (iso3166 | filter: {alpha_2: isoQuery})">
Everything is working as expected. Each item in the "iso3166" group has boolean values for "restricted", "unrestricted", and "unclassified", corresponding to the columns "license", "prohibited", and "size".
Users can set these values to true or false in each row:
https://i.stack.imgur.com/m0ck4.jpg
This functionality is working fine.
Now, I want to add an "ALL" row at the top that will apply the selected value to every item in the filtered set when clicked:
https://i.stack.imgur.com/0N6an.jpg
In simple terms, if a user clicks the "restricted" button in the "license" column of the "ALL" row, all rows should toggle their "restricted" license value. However, I am unsure about how to implement this logic in the code.
The current ng-click function is:
ng-click="setAll('col1','licensed')"
The corresponding function looks like this:
$scope.setAll = function (column, value) {
angular.forEach($scope.filteredItems, function (value, key) {
??
});
};
I need help with assigning the correct value to each row within the loop.