简体   繁体   中英

Facing Error while injecting second service into Controller AngularJS

I am having two services : A : accountService B : invoiceService

Controllers: A : TicketController. B : InvoiceController.

below is the definition of 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. but when I inject the same accountService to invoice controller it throws error. Below is the definition of 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

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. If you try to load InvoiceController before you defined the accountService you will get this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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