我正在尝试使用 $resource 从静态 json 文件中获取数据,这是代码片段:
angular.module('app.services', ['ngResource']).
factory('profilelist',function($resource){
return $resource('services/profiles/profilelist.json',{},{
query:{method:'GET'}
});
});
在控制器中,
function ProfileCtrl($scope,profilelist) {
$scope.items = [];
$scope.profileslist = profilelist.query();
for (var i=0;i<=$scope.profileslist.length;i++){
if($scope.profileslist[i] && $scope.profileslist[i].profileid){
var temp_profile = $scope.profileslist[i].profileid;
}
$scope.items.push(temp_profile);
}
但是现在,我面临一个错误:
TypeError: Object #<Resource> has no method 'push'
你能帮我解决我哪里出错了吗?