3 ms·
My interpertation of the AngularJS DI implementation is that it exists primarily to make it easy to swap items out for testing purposes. I believe it solves th
by reboog711 13y ago
My interpertation of the AngularJS DI implementation is that it exists primarily to make it easy to swap items out for testing purposes. I believe it solves that problem very well.
What alternatives do you recommend to DI?
- jeswin 13y agoNothing, for swapping things out. :) In my test initialization, I'd probably just replace the value of "ns.someService" worldwide with a mock.
- nocoment 13y ago> just replace the value of "ns.someService" worldwide with a mock. Having a window-wide namespace might make sense in the test, but it is pretty risky/limiting if you are writing a component that should be reused in contexts you don't fully control. There are other ways around that besides DI, but they will probably have similar trade-offs in safety EOU, etc.