简体   繁体   English

如何使用angular从具有多个参数的剩余URL中检索对象

[英]How to retrieve objects from rest url with multiple parameters using angular

How can i create a factory that can retrieve data from /rest/company/:companyid/employee/:id 我如何创建可以从/ rest / company /:companyid / employee /:id检索数据的工厂

when i use this url in the factory I get an error: Unknown provider companyidProvider 当我在工厂中使用此URL时,出现错误:未知提供程序companyidProvider

Thank you, 谢谢,

Kyle 凯尔

Service: 服务:

 app.factory('EmployeeByCompany', function ($resource,companyid) { return $resource('app/rest/company/:companyid/employee/:id', {}, { 'query': { method: 'GET', isArray: true}, 'get': { method: 'GET'} }); }); 

I'm guessing the error is from having the companyid as a parameter with $resource. 我猜测错误是因为将$$ source作为有companyid的参数。 What is the right way for a service to call this url? 服务调用此网址的正确方法是什么?

如果您正在学习或入门,请尝试Restangular https://github.com/mgonto/restangular

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM