dimanche 3 septembre 2017

Filtering list items with ng-repeat from a selection/de-selection of a combination of checkboxes

I have a list of items which are frequently updated, based on changes to a price property. If the price of an item falls below a certain value (below 5) that item has a 'selected' property set to true and displayed in the results table (filtered on the selected property).

ng-repeat="item in dataPrices | filter: {selected:true}"

I want to add a series of checkboxes which, based on the selection/de-selection of a combination of checkboxes used should further filter the results - zero to three selections are possible

<label ng-click="productType('large')">
        <input type="checkbox">
        <span>Large items</span>
</label>
<label ng-click="productType('small')">
        <input type="checkbox">
        <span>Small items</span>
</label>
<label ng-click="productType('medium')">
        <input type="checkbox">
        <span>Medium items</span>
</label>

I did try to add an additional filter to the ng-repeat

ng-repeat="item in dataPrices | filter: {selected:true} | filter: {size:'large'}"

which works, but I'm not sure how to add a combination of these based on the result of a combination of checkbox selection/de-selection. Any help would be GREATLY appreciated.

I have put this plunkr together which might make this a little clearer - http://ift.tt/2xHx71A




Aucun commentaire:

Enregistrer un commentaire