Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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!



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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: