Sorry to necro this question, but I struggled with this same issue and luckily found a solution. I'm no Angular expert so my solution might be done a better way, but hope this helps someone out there.
Looking at AngularJS' documentation for providers , their example states:
myApp.provider('unicornLauncher', function UnicornLauncherProvider() {});
And then they show how to inject that provider into a config function:
myApp.config(["unicornLauncherProvider", function(unicornLauncherProvider) {});
The important thing to note is the naming convention: The provider name doesn't have the word 'Provider' in it at the moment of declaration, yet the config injection does.
Like you, I'm also using a named function for my config. So my config injection declaration looked like:
angular.module('sample').config(['UserAgentProvider', config]);
However, you are doing it slightly different by using the .$inject
injector. So your end solution would look like:
angular.module('sample').config(config);
config.$inject = ['UserAgentProvider'];
I too was using the .$inject injector, but switched to the AngularJS documentation style syntax because of this:
Notice that the unicorn provider is injected into the config function. This injection is done by a provider injector which is different from the regular instance injector, in that it instantiates and wires (injects) all provider instances only.
Not sure if the .config(['MyNamedProvider', NamedConfigFunction])
is better vs. NamedConfigFunction.$inject = ['MyNamedProvider'];
But the important point is leaving off the 'Provider' during the declaration of the provider, but adding it back during the injection of said provider