使用几个参数获取元素计数 angularjs

get element count with a few parameters angularjs

我想使用 angular 的过滤器来过滤元素以检查 2 个属性,然后获取返回元素的数量

这是我试过的:

$scope.countPriorityActive = true;
$scope.getCountActive = function(strCat) {
    return filterFilterActive($scope.tasks, {priority: strCat, active: true}).length;
};

但它不起作用
我从编辑这个例子开始:http://plnkr.co/edit/8YbRTd?p=preview
我的错误是什么?

您忘记在数组的元素中添加 "active" 属性

{
  id: 1,
  name: 'Iron Man',
  fname: 'Tony',
  lname: 'Stark',
  location: 'Stark Tower',
  comic: 'Marvel'
  active: true //this is what you need to add to each element
},

您还需要调用 "filterFilter",而不是 "filterFilterActive",除非您自己制作了一个新过滤器