by marknutter · 12y ago · 0 comments
You've got to be joking. An Angular "module" is a chunk of code that happens to be given a collective name. There's no namespacing, no encapsulation, and no build/file management.
You don't really need to for angular development. Namespacing Javascript is a cargo cult practice brought over from more traditional OO languages.
> no encapsulation
There is if you want it to be. You're especially encouraged to separate the concerns of the DOM in directive services, for example.
> no build/file management
That's kind of up to you, isn't it? You can run with grunt/require if you want a headache, grunt or gulp / uglify if you want easy, you can run with gulp/browserify if you want the new cool ...
You're right about services providing encapsulation. I still wind up with a lot of awkward situations where directives can't work without knowing something about their parent scope. It's possible that's more my problem because it's getting less frequent as I abuse ng-model more and more, but also remember that isolate scope, up until very recently, worked in an incomprehensibly stupid way [1].
>grunt or gulp / uglify if you want it easy
Eh... not really that easy. At least, not if you want to anything more sophisticated than concat together every .js file in sight. Require, for all its problems and relative-path headaches, at least makes it dead simple to run in development without having to remember to either add another file to the list or wait for a rebuild every time you change something.
[1]: https://github.com/angular/angular.js/commit/909cabd36d77959...
Perhaps you're thinking of another language's definition of modular?
When "modules" can break each other because of purely internal implementation details, there is something very wrong.
So the Angular approach is modular, but slightly broken.