当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How to filter by property name inside controller in angular js

问题描述:

This is what I did so far:

 fourHunderds = $filter('filter')($scope.filterErrors, {StatusCode:"404"}).length;

$scope.filterErrors has StatusCode property but it seems length of the $scope.filterErrors and fourHunders are always the same (filtering is not working, this line of code doesn't work for me)

网友答案:

Unless you are using a predefined angular filter you can do this with Array.prototype.filter()

fourHunderds = $scope.filterErrors.filter(function(item){
                   return item.StatusCode == '404';
               }).length
分享给朋友:
您可能感兴趣的文章:
随机阅读: