How to filter multiple values (OR operation) in angularJS

前端 未结 20 1132
清酒与你
清酒与你 2020-11-22 10:01

I want to use the filter in angular and want to filter for multiple values, if it has either one of the values then it should be displayed.

I have for

20条回答
  •  醉梦人生
    2020-11-22 10:41

    I would just create a custom filter. They are not that hard.

    angular.module('myFilters', []).
      filter('bygenre', function() {
        return function(movies,genres) {
          var out = [];
          // Filter logic here, adding matches to the out var.
          return out;
        }
      });
    

    template:

    Movies

    Action
    Family
    {{genrefilters.action}}::{{genrefilters.family}}
    • {{movie.title}}: {{movie.genre}}

    Edit here is the link: Creating Angular Filters

    UPDATE: Here is a fiddle that has an exact demo of my suggestion.

提交回复
热议问题