与复选框Angularjs过滤 [英] Angularjs filtering with checkboxes

查看:125
本文介绍了与复选框Angularjs过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了如何创建使用复选框一个不错的反复过滤此的jsfiddle:

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

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

全部信贷堆栈溢出用户ExpertSystem此的jsfiddle(有没有什么办法来发送直接消息给其他用户吗?或者在这个岗位标记它们?)

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?)

我想知道,以便选择一个复选框,当此code如何进行编辑,它从显示屏删除相关项目(而不是只显示相关项目)。

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).

因此​​,在present当您检查红复选框,你会看到显示的:

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.

推荐答案

易peasy柠檬squeezy :)只是改变的情况下,检查的小提琴

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

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

这篇关于与复选框Angularjs过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆