0

I need to make one filter in angularjs app. In my database, I keep a string value to say if the data is ative or inative. I use 'S' to active and 'N' to inative. But I made a checkbox button in my page to filter the data returned of the database, to show inatives or not. But I need to convert the value returned of de checkbox button to 'S' or 'N'. How can I do it? I am trying using this code:

app.filter('cakeActive', function(){
return function(input){
    if(input == true){
        return 'S';
    }
    else {
        return 'N';
    }
};

});

And in my DOM, is this:

<input checked type="checkbox" ng-model="active">
        <div class="col s12 m12 l12" ng-repeat="cake in cakes | {cake.active == cakeActive:active}">...</div>

This is not working. What the best form to fix this situation? Thanks!

2
  • Why don't you fix the root problem and add proper types to your DB model? Commented Sep 15, 2016 at 12:58
  • 1
    You tried active|cakeActive? Commented Sep 15, 2016 at 12:59

1 Answer 1

1

You may use ng-true-value, ng-false-value for that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.