title: Modules and namespace / name collision in AngularJS
body: <p>Consider the following jfiddle <a href="http://jsfiddle.net/bchapman26/9uUBU/29/">http://jsfiddle.net/bchapman26/9uUBU/29/</a></p>
  
  <pre><code>//angular.js example for factory vs service
  var app = angular.module('myApp', ['module1', 'module2']);
  
  var service1module = angular.module('module1', []);
  
  service1module.factory('myService', function() {
      return {
          sayHello: function(text) {
              return "Service1 says \"Hello " + text + "\"";
          },
          sayGoodbye: function(text) {
              return "Service1 says \"Goodbye " + text + "\"";
          }
      };
  });
  
  var service2module = angular.module('module2', []);
  
  service2module.factory('myService', function() {
      return {
          sayHello: function(text) {
              return "Service2 says \"Hello " + text + "\"";
          },
          sayGoodbye: function(text) {
              return "Service2 says \"Goodbye " + text + "\"";
          }
      };
  });
  
  function HelloCtrl($scope, myService) {
      $scope.fromService1 = myService.sayHello("World");
  }
  
  function GoodbyeCtrl($scope, myService) {
      $scope.fromService2 = myService.sayGoodbye("World");
  }​
  </code></pre>
  
  <p>I have 2 modules (module1 and module2). Both module1 and module2 define a service called myService. This appears to create a name clash on myService within Angular when both modules are imported into myApp. It appears AngularJs just uses the second service definition without warning you of the possible issue.</p>
  
  <p>Very large projects (or just reusing modules in general) would have a risk of names clashing, which could be difficult to debug.</p>
  
  <p>Is there a way to prefix names with the module name so that name clashes don't happen? </p>