r/angularjs • • May 22 '15

This AngularJS modules/dependencies thing is a lie

http://michalostruszka.pl/blog/2015/05/21/angular-dependencies-naming-clash/
61 Upvotes

20 comments sorted by

View all comments

4

u/kshitagarbha May 22 '15

Well it will be gone soon anyway and we can do this:

import {hello as hello1} from 'thirdParty1';
import {hello as hello2} from 'thirdParty2';

and then just use hello1() hello2() without any DI

You can even do this now if you are using angular 1.4, you are transpiling your ES6 code and if each of the modules exports in the common fashion.

4

u/Capaj May 22 '15 edited May 22 '15

if you are using angular 1.4

Yes, you can use ES6 notation to load files instead of having script tags in html, but to register an injectable, you still have to use angular "module" notation. Quite a difference there.

You're right that it might be best to just use filters, controllers and directives because those are the only means how to manipulate the DOM in angular. Services and factories, you really should not use if you have ES6, AMD or CommonJS modules, because it just makes things more difficult.

I'll have to do a writeup about this.

2

u/elprophet May 22 '15

just use filters, controllers and directives ... Services and factories, you really should not use if you have ES6

That's actually a really good point, and will take developers a long way towards building 1.x apps that easily upgrade to 2.0.