If you have a project with thousands of JS functions and planning on using
AngularJS, I would say that module loader like RequireJS is a must.
However, I am not sure what you mean by *namespacing* and "particularly
file moves and re-namespacing". AngularJS is pretty lousy at namespacing
if you are referring to namespacing at the module level. For example:
angular.module("sh.Shell", []).controller("MainController", ...);
angular.module("ct.CashTrading", []).controller("MainController", ...);
Code above will yield a single instance of MainController after loading
both modules. Therefore, the namespacing need to be applied at the
individual component level:
angular.module("sh.Shell", []).controller("sh.MainController", ...);
angular.module("ct.CashTrading", []).controller("ct.MainController", ...);
This make any namespacing refactorings even trickier. RequireJS can help
if you create a namespace attribute in a module and use it to push it down
to dependent components:
// Shell/ShellModule.js file
define(function () {
var shell = angular.module("sh.Shell", []);
shell.namespace = "sh";
return shell;
});
// Shell/Controller/MainController.js file
define(['Shell/ShellModule'], function (mod) {
mod.controller(mod.namespace + ".MainController", ...);
});
But this really only solve the creation part. As for *separate JS file, *you
can use RequireJS optimiser (r.js) to combine files that would be loaded on
demand.
I created angularAMD to help me manage my AngularJS/RequireJS projects
Take a look to see if can help you:
http://marcoslin.github.io/angularAMD/
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.