mercredi 13 avril 2016

AngularJS: Update ng-repeat when checkbox state (as filter) is changed by code

I have an element which get filled by ng-repeat="item in items | filter:isselected(item)".

For the filter I created checkboxes with ng-model="selecteditem[$index]" and the filter

$scope.selectedItems = [];
$scope.isselected = function(item) {
    return function(i) {
        for (var a in $scope.selectedItems) {
            if (i.name == $scope.selectedItems[i]) return true;
        }
    };
};

The checkboxes are hidden and usually triggered by clicking a , but I also need to trigger them by code (I only want four checkboxes to be checked at the same time, so I created a directive that successfully checks how many are checked and unchecks the latest box if it is no. 5). But unfortunately the filter and thus the ng-repeat items are not refreshed by changing states because the filter is evaluated by a function.

So any ideas how to solve this or work around it?

http://ift.tt/1TRZwZP




Aucun commentaire:

Enregistrer un commentaire