Reputation: 518
I have 3 modules: core, util and test.
With dependencies set up like this I get error on initializing core module, because it can't find provider from util. If I remove this provider injection, everything works fine.
I don't know what I'm doing wrong.
var util = angular.module('util', []);
var core = angular.module('core', ['util']);
var test = angular.module('test', ['core', 'util']);
core.provider('core.OC', ['util.Path', function(Path){
this.$get = function(){
return {
get: function() { return 'OC!';}
}
};
}]);
util.provider('util.Path', function(){
this.$get = function(){
return {
get: function() { return 'Path!';}
}
};
});
test.controller('MainCtrl', ['$scope','util.Path', function($scope, Path) {
$scope.name = Path.get();
}]);
Here's plnkr of this setup: http://plnkr.co/edit/7VhdrdleNXHqqucSUcv9
Upvotes: 0
Views: 312
Reputation: 2141
Try injecting util.Path into your factory function instead. The provider call for core.OC is run to early to inject util.Path. You have to inject it later, when the factory function is run.
http://plnkr.co/edit/7vBszzVlo14q0pljOarv?p=preview
core.provider('core.OC', function(){
this.$get = ['util.Path', function(Path){
return {
get: function() { return 'OC!';}
}
}];
});
Upvotes: 1