Inject service in app.config
angularjs
Solution
Alex provided the correct reason for not being able to do what you're trying to do, so +1. But you are encountering this issue because you're not quite using resolves how they're designed.
`resolve` takes either the string of a service or a function returning a value to be injected. Since you're doing the latter, you need to pass in an actual function:
resolve: {
data: function (dbService) {
return dbService.getData();
}
}
When the framework goes to resolve `data`, it will inject the `dbService` into the function so you can freely use it. You don't need to inject into the `config` block at all to accomplish this.
Bon appetit!
Problem
I want to inject a service into app.config, so that data can be retrieved before the controller is called. I tried it like this: Service: ``` app.service('dbService', function() { return { getData: function($q, $http) { var defer = $q.defer(); $http.get('db.php/score/getData').success(function(data) { defer.resolve(data); }); return defer.promise; } }; }); ``` Config: ``` app.config(function ($routeProvider, dbService) { $routeProvider .when('/', { templateUrl: "partials/editor.html", controller: "AppCtrl", resolve: { data: dbService.getData(), } }) }); ``` But I get this error: Error: Unknown provider: dbService from EditorApp How to correct setup and inject this service?