0

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.

1
  • You could do a check using the ng-if directive and a custom function bound to that. Like this: jsfiddle.net/wzv7w24o Commented Feb 5, 2016 at 11:24

1 Answer 1

3

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

$scope.filterByCategory = function (wine) {
    console.log($scope.filter);
    return !$scope.filter[wine.category];
};
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.