Hacker News new | ask | show | jobs
by piranha 4696 days ago
Well, in my option DI is one of the worst parts of Angular. It's a module system which can't be integrated with anything. Doing something like commonjs/amd would be much nicer:

app.controller('Name', function(require) { var $scope = require('$scope'); var y = require('some-service'); });

And suddenly, no problems and no weird syntax!

1 comments

Require is a service locator, so you are getting some of the inversion of control benefits, but I greatly prefer the injections of the dependencies I need instead of relying on a locator.

In practice the DI approach is very nice, and works consistently. It also makes unit tests more straight forward.