2

I'm building an AngulrJS module that I intend to share, for free, with other developers via GitHub/bower. While my approach currently works, I'm concerned about name collisions. The way that I am currently setting up my module is like this:

var myModuleName = angular.module('myModuleName', []);
myModuleName.factory('$myFirstServiceName', function() {
 ...
});

myModuleName.factory('$mySecondServiceName', ['$q', function($q) {
 ...
}]);

myModuleName.factory('$myThirdServiceName', ['$q', function($q) {
 ...
}]);

My concern is that global 'myModuleName'. While this approach works, the name of my module isn't that "special". For that reason, I'm concerned it will collide with a developers existing stuff or cause other problems down the road.

Is there any way to more elegantly create a module where I don't have to worry about naming collisions?

Thank you!

4
  • Why don't you just name the module something special? I'm pretty sure that the only way that you are going to avoid naming collisions is to have a unique name. Commented Aug 28, 2014 at 13:39
  • I'm open to that. I was asking more for the purpose of education. I was wondering if I was doing something incorrectly or not. Commented Aug 28, 2014 at 13:45
  • Interesting question. I think for the actual name of the module you'll have to be unique. For the var myModuleName: I think minification is the way that would normally prevent this. Commented Aug 28, 2014 at 13:50
  • I wouldn't think too much about a unique name. Name the module with a name that describes the functionality what it actually does. Chances are, that developers only pick one module for one job. Commented Aug 28, 2014 at 14:18

1 Answer 1

0

You can use prefix in module name, which present project/library/author.

Like pasvaz.bindonce, ui.router etc...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.