javascript - 使用 angularjs 获取休息服务

标签 javascript ajax json angularjs rest

我是 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/

相关文章:

javascript - ReactJS:如何最好地处理新创建对象的 JSON 响应

javascript - Django + Jquery

javascript - 没有使用 wp_query 插件的 WordPress REST API

javascript - 页面加载更改输入值并触发

ajax - 谷歌浏览器转义所见即所得的 Javascript

javascript - 需要有关我的 jQuery 脚本的帮助

javascript - 如何使用 JavaScript 从 BING map API 获取地址(城市、州、国家、邮政编码)?

java - 尝试将api中的数据获取到JSON时在JSONArray上使用NullPointer

json - Swift:无法使用 'decode' 类型的参数列表调用 '([Idea], from: Data)'

javascript - 使用 jquery 单击时显示第一项并显示/隐藏其他项