I'm still fairly new to Angular, and am trying to wrap my brain around something that I hope someone can shed a little light on for me...
I've got a module that has a robust (singleton) service in it that I want some of my other components to be able to access. I've currently got it exporting with the static forRoot(): ModuleWithProviders
stuff, and importing into "app.module.ts".
Now, I can get it to work successfully. If, in the component to use the service, I add an import statement like this:
import { XyzService } from '../../modules/xyz/xyz.service';
and inject it into the component's constructor:
constructor(private _xyzr: XyzService) { }
But that seems too tightly coupled. Every single component has to import the module's service? Is that the right way to do this? Is there a better way? Something that would allow me to swap out the module for a newer/better one on down the road without having to go touch every single component...
Thanks!