Multiple check-box selection and create a tag base

2019-09-21 05:48发布

问题:

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

回答1:

Sounds like you are looking for some pre-built code.

You can use Angular-multi-select in combination with a custom filter.



回答2:

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