Hacker News new | ask | show | jobs
by badman_ting 4471 days ago
I think DI in Angular should be an opt-in thing, too confusing otherwise. I've had moments where I thought I was just writing a regular function, and then Angular started throwing exceptions because it was trying to inject dependencies based on the argument names. (And the solution was to write a function with no arguments that returned the actual function with arguments!)

There are conventions around what string maps to what thing, so that sometimes strings like "controller" or "provider" are inferred and not required to be specified. This is bad -- things should just be referred to by their full names.

It would be nice to have the ability to ask for things directly in require-style function calls instead of having them be parameters to a function. It's actually sort of crazy that you can define a controller (for example) with angular.controller('MyController', function(){}), but then you can't ask for it back with angular.getController('MyController'), or whatever.

All this makes it a lot harder to try things out in the console, and lengthens the feedback loop of determining what works and what doesn't.

And I didn't even know about the minification thing. That is legitimately terrible.

1 comments

You need DI to do unit tests properly.
Isn't the problem Automatic DI, and not DI?