“Namespacing” services in AngularJS

As of today AngularJS doesn’t handle namespace collisions for services so if you’ve got 2 different modules with the service named the same way and you include both modules in your app, only one service will be available.

For the moment the best option is to prefix service names with a custom prefix, ex:

angular.module('myprefix_mymodule',['dep1', 'dep2']).factory('myprefix_MyService', ...)

Leave a Comment