I am trying to create a service in a module which is dependent on another service in another module but the services have the same name. Consider the following example:
angular.module('module1',[]).factory('log', [function () {
return { show: false, msg: "" };
}]);
angular.module('module2', ['module1']).factory('log', ['log', function (log) {
return { show: false, msg: log.msg + "" };
}]);
angular.module('myapp', ['module2']);
When I implement the above code get: Error: [$injector:cdep] Circular dependency found: log
I understand that services are singleton in angular [1] and the dependency injection follows last one wins convention [2]. Seems to me that in 'module2', 'log' that gets injected is itself hence the circular dependency. How do I inject 'log' from 'module1'?