Filtering on object map rather than array in AngularJS

前端 未结 6 2124
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 05:15

Given a controller with a $scope property that is an object with other properties rather than an array like below, how should I filter the ng-repeat set?

6条回答
  •  既然无缘
    2020-12-03 05:44

    Rather than using a filter you can also simply :

    $http.get('api/users').success(function(data){
        angular.forEach(data, function(value, key){
            users.push(value);
        });
        $scope.users = users;
    });
    

    And in the template

    
    
    
  • {{ user.name }}
提交回复
热议问题