So I got a project which is using AngularJS with UI-Router, I iterate through a json which has a property called "state" which is what I want to use as a filter, however, I will be using a "selector" where I can pick "All" or a specific one.
I'm new to AngularJS So not sure exactly what is not working, this is the code I have so far:
function filterState (installment){
switch(selectedValue) {
case 1:
if(installment.state === 'PAID'){
return installment;
}
break;
case 2:
if(installment.state === 'LATE'){
return installment;
}
break;
case 3:
if(installment.state === 'PENDING'){
return installment;
}
break;
default:
return installment;
}
The filter however is not working as it should Here is how I'm calling it:
<div class="row" ng-repeat="installment in vm.clients.installments | filter: filterState">
Not sure exactly what is the error, when I filter by a value manually like filter: {state:'PAID'} It works
Apparently I needed to return a boolean value instead of the object, I did try that before, but my other issue was that I was calling the function directly instead of doing vm.function (once passed to the context), after doing that it worked.