I'm looking at managing my AngularJS code using RequireJS and have come up with the following pattern:
"use strict";
(function () {
var moduleName = "module.name";
define(
[
'angular'
],
function (
ng
) {
ng.module(moduleName, []);
return moduleName;
}
);
})();
I guess the general idea is that whenever my module/controller/etc... is included, rather than returning the object itself, it binds it's name into Angular and then returns that handle to the caller.
One question I have - Would it be a better idea to return the array parameter I'm passing to ng.module
and then eliminate the call, allowing the "includer" of this module to decide what name to bind to?
Are there any other pitfalls or recommendations for designing nicely encapsulated AngularJS+RequireJS modules that could be applied to this pattern? Anything I should watch out for to avoid hardship or confusion in the future?