-
Notifications
You must be signed in to change notification settings - Fork 27.5k
How about using require()
and define()
for modules?
#9267
Comments
I like the idea, but it's really just a convenience thing. Once you understood how it works, it's not that difficult. |
I might be missing something, but this seems like it could be implemented as a bit of a polyfill; define our own angular.define() and angular.require() - and they just alias angular.module():
Am I missing something? |
@Earl-Brown, the general idea sounds about right. A couple of things to note:
|
#1 - wouldn't
do the job, then? #2 - good point to remember ... does it invalidate my idea? (honest, I'm asking for information, not pushing a personal agenda...sometimes people mistake my approach for that) |
(1) Nope. (2) Nope (it doesn't invalidate your idea - it's just something to take into account). |
So ...
|
No, it's something that only affects the Something like: angular.require = function require(moduleName) {
return angular.module(moduleName);
};
angular.define = function define(moduleName, deps, configFn) {
return angular.module(moduleName, deps || [], configFn);
}; |
Ah...OK. Thanks! |
I do think that this more useful as a 3rd party module. In core, this would be just another way to do something you can already do. And the module concepts are pretty fixed and won't change in 1.x anyway. |
The current pattern for defining (or getting) a module is rather error-prone:
There are at least two issues:
module
) is used for reading and writing. This is kinda similar to JQueryattr()
function which can read or write depending on how it is called, but it's error prone and not very intuitive.How about using a pattern that already exists?
require()
anddefine()
:The text was updated successfully, but these errors were encountered: