Angularjs filtering with checkboxes

I have seen this jsfiddle of how to create a nice toggling filter using checkboxes:

http://jsfiddle.net/ExpertSystem/wYfs4/3/

Full credit to Stack Overflow user ExpertSystem for this jsfiddle (is there any way to send direct messages to other users? Or tag them in this post?)

I would like to know how this code could be edited so that when a checkbox is selected, it removes the relevant items from the display (as opposed to only displaying the relevant items).

So at present when you check the "red" checkbox you will see displayed:

Wine A (red)
Wine B (red)
Wine D (red)
Wine E (red)

But what I want to see is:

wine C (white)
wine F (white)
wine G (champagne)
wine H (champagne)

So essentially I'm looking to reverse the filter. I have played around a little bit, but have had no luck so far and I'm not really sure how to go about it.

Answers:

Answer

easy peasy lemon squeezy :) just change the condition, check the Fiddle

$scope.filterByCategory = function (wine) {
    console.log($scope.filter);
    return !$scope.filter[wine.category];
};

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.