简体   繁体   English

将多个参数从控制器传递到服务angularjs

[英]Passing multiple parameters from controller to service angularjs

Hi I am trying to figure out how to pass multiple ids to the service from my controller. 嗨,我试图找出如何将多个ID从控制器传递给服务的方法。

In my controller I am calling the service with two parameters, t1 and t2 在我的控制器中,我使用两个参数t1和t2调用服务

  projEstimatesRepository.updateEstimate.update({ id: t1 }, function(data) {
                    alert("Estimates have been added sucessfully");
                });

In my factory I have 在我的工厂里

updateEstimate: $resource('/api/estimates/P_estimate/:id', {id:'@id'}, {update: {method: 'PUT'}})

It works fine. 工作正常。 Except I need to pass t1 and t2 from controller to the service. 除了我需要将t1和t2从控制器传递到服务。 Please let me know how to pass them Thanks 请让我知道如何通过他们谢谢

Just add it as you did with id : 就像添加id一样添加它:

updateEstimate: $resource('/api/estimates/P_estimate/:id/:id2', {id:'@id', id2:'@id2'}, {update: {method: 'PUT'}})

and then call as: 然后调用为:

projEstimatesRepository.updateEstimate.update({ id: t1, id2: t2 })

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

相关问题 在angularjs中将多个参数从控制器传递到工厂 - Passing multiple parameters from controller to factory in angularjs 将数据从AngularJS服务传递到AngularJS控制器 - Passing Data from AngularJS Service to AngularJS Controller AngularJS-将参数从指令传递回控制器 - AngularJS - Passing parameters from directive back to the controller 将错误消息从服务传递到angularjs中的控制器 - passing error message from service to controller in angularjs AngularJS - Controller资源调用没有将参数传递给服务工厂? - AngularJS - Controller resource call not passing parameters to service factory? 将数据从AngularJs服务传递到控制器,再将控制器传递到控制器 - Passing the data from AngularJs Service to Controller and Controller to Controller 将参数传递给AngularJS控制器方法 - Passing parameters to AngularJS controller methods 将多个参数从角度传递到休息服务 - Passing multiple parameters from angular to rest service 将参数从控制器传递到angularjs中的资源工厂以在数据库中进行搜索 - passing parameters to resource factory in angularjs from controller to search in database 将数据和变量从服务传递到AngularJS和PouchDB中的控制器 - Passing data and variables from service to controller in AngularJS and PouchDB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM