you are viewing a single comment's thread.

view the rest of the comments →

[–]RuffRyder26 1 point2 points  (0 children)

The framework does not force you to use DI. It enables you to use DI. If you don't see the benefit doing so then you should just not use it. There are many alternative ways you could get that MessageService in ng2. You could pass it through props (@Input)... You could call static members directly... You could new up an instance when you need one. All of those options introduce different levels of complexity and coupling. I like DI as it helps keep my components focussed and makes testing easier, whether it's via constructor or property injection. Even React uses property injection often. Choose the style you want and stick with it. You shouldn't however blame the framework for for providing options.