Lets say I have a controller, which depends on two modules that both contain a directive or a service with the same name. Can I specify which one exactly should be used?
angular.module('myApp', ['secondModule', 'thirdModule'])
.controller('Ctrl1', ['$scope', 'myService', function(scope, myService){
scope.user = myService.getUser();
console.log(myService);
}]);
In this case both secondModule and thirdModule have a service called myService. But only the one from the thirdModule will be used in this example. I tried putting something like secondModule.myService as a dependency for Ctrl1, but it wouldn't work. Is there some kind of namespacing in AngularJS?
At the moment, no, there is no module based namespacing. You'll have to avoid collisions on your own.
I believe there was some discussion about this, but I can't find it at the moment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With