多个复选框选择并根据所选选项创建标签,并过滤掉 AngularJs 中的数据 [英] Multiple check-box selection and create a tag based on selected option and also filter out the data in AngularJs

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

问题描述

我想使用 check-box 提供多项选择,并根据它使用 angular 指令 创建一个 tag.如果用户选择多个复选框,则根据 tags 应创建,如果用户删除任何标签,则应取消选中复选框.所以根据选择和删除标签数据应该filter出来.

这是我的工作 代码

提前致谢.

解决方案

//FILTER

 .filter('findobj', function () {返回函数(dataobj,multipleVlaue){if (!multipleVlaue) 返回数据对象;返回 dataobj.filter(function (news) {var tofilter = [];angular.forEach(multipleVlaue,function(v,i){tofilter.push(v);});返回 news.CategoryList.some(function (category) {return tofilter.indexOf(category.DisplayName)>-1;});});};})

<块引用>

这里你可以参考解决方案

I want to provide multiple selection using check-box and depending on that it will create a tag using angular directive. If user selects multiple check-box then according to that tags should create and if user remove any tag then check-box should be unchecked. So depending on a selection and a removal of tag data should be filter out.

Here is my Working CODE

Thanks in Advance.!

解决方案

//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 the Solution

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

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