Javascript 使用angularjs获取rest服务

Javascript 使用angularjs获取rest服务,javascript,ajax,json,angularjs,rest,Javascript,Ajax,Json,Angularjs,Rest,我是新来的。我试图从具有以下JSON格式的rest服务获取信息 [{ "participantMemberPK": { "memberId": 1, "participantId": 2 } }, { "participantMemberPK": { "memberId": 1, "participantId": 8 } }, { "participantMemberPK": { "memberId": 2, "participantId": 7 } }, { "participantMe

我是新来的。我试图从具有以下JSON格式的rest服务获取信息

[{ "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
错误:a.push不是一个函数
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/请参见下面zancudo对解决方案的评论(只是缺少了几行)。

请参见下面zancudo对解决方案的评论(只是缺少了几行)。

您能否在Codepen、JSBin或类似工具上举一个简单的例子?在.push之前的“a”是什么?我按照@kiswa的建议在Codepen中添加了我的代码。看来它现在正在工作。谢谢你能在Codepen、JSBin或类似的东西上举个简单的例子吗?在.push之前的“a”是什么?我按照@kiswa的建议在Codepen中添加了我的代码。看来它现在正在工作。谢谢嗨,kiswa。在我的代码中,我没有按照相应的json格式{{m.participantMemberPK.memberId}{{m.participantMemberPK.participantId}}@zancudo-Ah正确地包含这些行。也许把它作为一个答案,并标记它,让未来的游客知道问题是什么?如果你愿意,我也可以编辑我的。嗨@kiswa。在我的代码中,我没有按照相应的json格式{{m.participantMemberPK.memberId}{{m.participantMemberPK.participantId}}@zancudo-Ah正确地包含这些行。也许把它作为一个答案,并标记它,让未来的游客知道问题是什么?如果你愿意,我也可以编辑我的。