简体   繁体   English

将第二个服务注入Controller AngularJS时遇到错误

[英]Facing Error while injecting second service into Controller AngularJS

I am having two services : A : accountService B : invoiceService 我有两个服务A :accountService B :invoiceService

Controllers: A : TicketController. 控制器: A :TicketController。 B : InvoiceController. B :InvoiceController。

below is the definition of TicketController: 以下是TicketController的定义:

angular.module("app").controller('TicketController', ['$scope', '$http', '$rootScope', 'uploadManager', 'ticketService', 'accountService', function ($scope, $http, $rootScope, uploadManager, ticketService, accountService) {

}]);

In Above controller accountService is working perfectly fine. 在上述控制器中,accountService工作正常。 but when I inject the same accountService to invoice controller it throws error. 但是当我向发票控制器注入相同的accountService时,它将引发错误。 Below is the definition of invoiceController: 以下是invoiceController的定义:

angular.module("app").controller('InvoiceController', ['accountService', 'invoiceService', function (accountService, invoiceService) {

}]);

when i execute it, it throws error: Error when I execute the above code for invoiceController 当我执行它时,它会引发错误: 当我为invoiceController执行以上代码时出错

can anyone help what could be the problem? 任何人都可以帮助解决什么问题?

Thanks in Advance. 提前致谢。

The code we can see looks perfectly fine. 我们可以看到的代码看起来很好。

Make sure that in your index.html that you load the files in the right order. 确保在index.html中以正确的顺序加载文件。 If you try to load InvoiceController before you defined the accountService you will get this error. 如果您在定义accountService之前尝试加载InvoiceController ,则会收到此错误。

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

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