基于选择基于期权的选择和创建标签过滤AngularJs数据 [英] AngularJs filtering data based on option selection and tag creation based on selection
本文介绍了基于选择基于期权的选择和创建标签过滤AngularJs数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的code:的jsfiddle
-
Initialy它应该显示的所有数据。
-
我能够添加新的
标记
,并根据标记
选择数据过滤,但数据如果新的标记
被选中,如果标记
被删除的数据应该被删除应该在现有的过滤后的数据低于添加。
解决方案
最后
一切
得到解决。
块引用>//过滤器
.filter('findobj',函数(){
返回功能(dataobj,multipleVlaue){
如果(!multipleVlaue)返回dataobj;
返回dataobj.filter(函数(消息){
变种tofilter = []; angular.forEach(multipleVlaue,函数(V,I){
tofilter.push(五);
}); 返回news.CategoryList.some(函数(类){
返回tofilter.indexOf(category.DisplayName)-1个;
}); });
};
})这里u可以参考: code
Here is my code : Jsfiddle
Initialy its should display all the data.
I'm able to add new
tags
and based ontag
selection data is filtering but data should be added below the existing filtered data if newtag
is selected and data should be removed iftag
is deleted.
解决方案finally
Everything
is resolved.//FILTER
.filter('findobj', function () { return function (dataobj, multipleVlaue) { if (!multipleVlaue) return dataobj; return dataobj.filter(function (news) { var tofilter = []; angular.forEach(multipleVlaue,function(v,i){ tofilter.push(v); }); return news.CategoryList.some(function (category) { return tofilter.indexOf(category.DisplayName)>-1; }); }); }; })
Here u can refer : CODE
这篇关于基于选择基于期权的选择和创建标签过滤AngularJs数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文