ng-repeat :filter by single field

后端 未结 12 2299
栀梦
栀梦 2020-11-22 10:06

I have an array of products that I\'m repeating over using ng-repeat and am using

<
12条回答
  •  温柔的废话
    2020-11-22 10:58

    Best way to do this is to use a function:

    html

    javascript

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

提交回复
热议问题