I just noticed a bug in my app. I'm filtering on several options and I set the filter to strict, but it is not acting strictly.
ng-repeat="(cat, prodGrp) in products | filter:search:strict | groupBy: 'productGroup'"
data:
filterOptions: {
"riskTolerance": ["Moderate", "Moderately Aggressive", "Aggressive"]
},
productList: [{
"title": "Scott Awesome Product",
"riskTolerance": ["Aggressive"],
"description": "Leverages good stuff\r\n",
"productGroup": "Group 1"
}, {
"title": "Test Product",
"riskTolerance": ["Moderately Aggressive", "Moderate"],
"description": "Offers good stuff\r\n",
"productGroup": "Group 1"
}
I'm using filterOptions to create a selectbox of each item in that array. However, I'm getting both products if I select 'Aggressive' which is strange, since I'm selecting 'strict'.
I looked at https://docs.angularjs.org/api/ng/filter/filter, but their example doesn't use all of the available filter properties and I'm not sure if there's another property I can reference that would make this work.
Any help would be greatly appreciated.
Update
Thanks, JB Nizet. I now know I should use :true, instead of :strict. But because I now put ":true" everywhere, when I select the "All" option of the drop-downs, I can't get the entire list to show since it's trying to match the "" to the value, strictly.
So, I've implemented the customized filter found here: https://stackoverflow.com/a/28745675/203141
$scope.filterByCategory = function (input, search_param) {
return search_param === "" || angular.equals(input, search_param);
};