I’m new to Meteor but excited about its capabilities as an full stack platform and its integration with Angular2 via the angular-meteor project.
I am interested in using Angular2 dependency injection on the server code to keep similar coding style and promote code reuse across the stack. Is this possible and, if so, how?
I am disappointed to not have gotten an answer from this forum, the Angular-Meteor room on Gitter.IM or the Angular-Meteor tag on StackOverflow, but still quite pleased to have found the answer myself in this very clear and simple article on Using Angular Dependency Injection in Node, which was fairly straightforward to adapt to the Angular-Meteor /server
setup.
Update: Since Angular 5 has deprecated the ReflectiveInjector
in favor of the StaticInjector
, we had to adjust our solution. However, it was simply a matter of changing project dependencies and module imports to use injector-js
, a package where the original Angular ReflectiveInjector
code is now being maintained separately.