Inject dependencies in “run” method of the module in Angularjs

I think that the reason

App.$inject = [CONFIGURATION, LOG_SERVICE];

doesn’t work, is because you have 2 other parameters $rootScope & $location that you need to inject in the $inject. So it needs to be:

App.$inject = ["$rootScope", "$location", CONFIGURATION, LOG_SERVICE];

Another way you can inject your service is to use this version:

app.run(["$rootScope", "$location", CONFIGURATION, LOG_SERVICE, 
         function ($rootScope, $location, Configuration, LogService) {

}] );

Leave a Comment