AngularJs 基于选项选择过滤数据,基于选择创建标签 [英] AngularJs filtering data based on option selection and tag creation based on selection

查看:20
本文介绍了AngularJs 基于选项选择过滤数据,基于选择创建标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:Jsfiddle

  1. 最初它应该显示所有数据.

  1. Initialy its should display all the data.

我可以添加新的 tags 并且基于 tag 选择数据正在过滤,但如果新 tag 被选中,如果 tag 被删除,数据应该被删除.

I'm able to add new tags and based on tag selection data is filtering but data should be added below the existing filtered data if new tag is selected and data should be removed if tag is deleted.

推荐答案

终于一切都解决了.

//过滤器

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

         });
     };
     })

这里你可以参考:代码

这篇关于AngularJs 基于选项选择过滤数据,基于选择创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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