Angular.js ng-repeat filter by property having one of multiple values (OR of values)

后端 未结 7 1528
一向
一向 2020-12-01 05:58

Is it possible to filter an array of objects, such that the value of property can be either of a few values (OR condition) without writing a custom filter

7条回答
  •  青春惊慌失措
    2020-12-01 06:33

    Best way to do this is to use a function:

    $scope.myFilter = function (item) { return item === 'red' || item === 'blue'; };

    Alternatively, you can use ngHide or ngShow to dynamically show and hide elements based on a certain criteria.

提交回复
热议问题