I have a module. It has a config block, a provider, and a constant defined. The config block references both the constant and the provider. I notice that my constant can be defined before or after my config block. The provider however must be defined BEFORE the config block or else I get an error.
Error: [$injector:modulerr] Failed to instantiate module loadOrder due to:
[$injector:unpr] Unknown provider: greetingsProvider
Here is some sample code:
var myModule = angular.module('loadOrder', []);
//if I define this after the config block, I get an error
angular.module('loadOrder').provider('greetings',[ function(){
this.$get = [function(){
return { greet: function(){ return "Hola"; } };
}];
}]);
myModule.config(['$provide', 'greetingsProvider', 'planetName', function($provide, loadOrderProvider, planetName){
$provide.value('someVals',[3,6,8]);
console.log("Lets go to", planetName);
}]);
myModule.constant('planetName', 'Saturn');
Why is this? Why can't I define my provider after my config block?