I am working on an AngularJS app and need to create a filter. In my database, I have a string value that indicates whether the data is active or inactive. I use 'S' for active and 'N' for inactive. I added a checkbox button on my page to filter the data retrieved from the database, to show inactive items or not. However, I need to convert the value of the checkbox button to 'S' or 'N'. How can I achieve this? Currently, I'm trying to implement the following code:
app.filter('cakeActive', function(){
return function(input){
if(input == true){
return 'S';
}
else {
return 'N';
}
};
});
And in my DOM, I have:
<input checked type="checkbox" ng-model="active">
<div class="col s12 m12 l12" ng-repeat="cake in cakes | {cake.active == cakeActive:active}">...</div>
However, this implementation is not working as expected. What would be the best approach to fix this issue? Thanks!