I have a list of items and I need 3 filters for it. 1 of the filters is a simple name search. 2 of these filters are checkboxes that a user can toggle to adjust their data.
Previously, when I wasn't using checkboxes (and only allowing a single value for each filter), the below line allowed all filters to be used:
'<tr ng-repeat="item in data.itemList | orderBy: orderField | filter: {attr1 : a1Value} | filter: {attr2: a2Value} | filter: {attr3 : a3Value}">'
But now that I'm using checkboxes, this no longer works. Here is what I am trying so far. HTML:
'<!--list of checkboxes-->
<dl>
<dt ng-repeat="type in data.att1List">
<input type="checkbox" ng-model="a1Obj[type]">
</dt>
</dl>
<!--...-->
<!-- list of data items -->
<tr ng-repeat="item in data.itemList | orderBy: orderField | filter: {attr1 : a1Filter} | filter: {attr2: a2Obj} | filter: {name : nameValue}">
<!--...-->'
in the controller i have:
'$scope.a1Obj= {
'type1' : true, <!-- initialize 1 checkbox -->
'type2' : false,
'type3' : false
};`
$scope.a1Filter = function (itm) {
return $scope.a1Obj[itm.attr1];
};'
What am I missing? Does anyone have any insight on chaining multiple filters where 1 or more are checkboxes?
Aucun commentaire:
Enregistrer un commentaire