Multiple check-box selection and create a tag based on selected option and also filter out the data in AngularJs

时光怂恿深爱的人放手 提交于 2019-12-13 09:54:20

问题


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



来源:https://stackoverflow.com/questions/31553990/multiple-check-box-selection-and-create-a-tag-based-on-selected-option-and-also

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!