angularjs custom filter to check for values inside a data array

后端 未结 5 965
野趣味
野趣味 2020-12-02 02:34

I have two filters which filter the data according to the queue key in the data. Here is my code :

5条回答
  •  余生分开走
    2020-12-02 03:30

    I think you can do it like this. It is not clear what it is exactly what you want to do because your code is overly complicated and badly aligned.

    app.filter('searchFilter',function($filter) {
      return function(items, searchfilter) {
          const terms = Object.values(searchfilter).map(
              (val)=>val.toLowerCase(),
          );
          return items.filter((item) =>
              item.queuearr.some((q) => terms.includes(q.queue.toLowerCase())),
          );
      };
    }
    

提交回复
热议问题