我是 Angular 新手。我正在尝试从具有以下 JSON 格式的休息服务获取信息
[{ "participantMemberPK": { "memberId": 1, "participantId": 2 } },
{ "participantMemberPK": { "memberId": 1, "participantId": 8 } },
{ "participantMemberPK": { "memberId": 2, "participantId": 7 } },
{ "participantMemberPK": { "memberId": 3, "participantId": 7 } },
{ "participantMemberPK": { "memberId": 3, "participantId": 8 } },
{ "participantMemberPK": { "memberId": 4, "participantId": 1 } },
{ "participantMemberPK": { "memberId": 5, "participantId": 9 } },
{ "participantMemberPK": { "memberId": 6, "participantId": 10 } }]
我的工厂正在返回:
return $resource(restUrl, {}, {
get: {
method : 'GET',
params : {},
isArray: true }
}
};
运行应用程序时出现错误:
Error: a.push is not a function
fa@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:11:302
Resource@https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-resource.js:401:9
resourceFactory/</Resource[name]/promise</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-resource.js:482:19
n@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:7:308
resourceFactory/</Resource[name]/promise<@https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-resource.js:481:17
f/<@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:120:98
hf/this.$get</m.prototype.$eval@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:134:387
hf/this.$get</m.prototype.$digest@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:131:419
hf/this.$get</m.prototype.$apply@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:135:159
l@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:87:139
N@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:91:187
Rf/</x.onload@http://127.0.0.1:8020/angularBIOS/scripts/angular.min.js:92:220
有什么帮助吗?谢谢
最佳答案
请参阅下面 zancudo 的评论以获取解决方案(只是缺少一些行)。
关于javascript - 使用 angularjs 获取休息服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31250124/