我在PHP-Reports
中使用自定义过滤器:
ng-repeat
并过滤:
item in filtered = (project.data.campaigns | filter:isStatus() | filter:isCategory()) | orderBy : 'created_at'
如果,如果 $scope.isStatus = function() {
return function(item) {
var status = $scope.inArray($scope.filterObj.status, item.status);
console.log(status);
return status;
};
};
为空,则返回$scope.filterObj
中的所有项目?
简单,如果ng-repeat
为false,则返回所有项
答案 0 :(得分:2)
尝试:
$scope.isStatus = function() {
return function(item) {
// false if filterObj is null
// since ECMAScript 5.1 you can also use Object.keys
if ($scope.filterObj && Object.keys($scope.filterObj).length > 0) {
return $scope.inArray($scope.filterObj.status, item.status);
}
return item;
};
};