DeborahKon Stack Overflow • Recommends
On “Angular 6 providedin doesn't work -> StaticInjectorError”
98% of the time, use providedIn = 'root'. It will register the service with the root application injector, will be tree shaken, and will be available to any component that needs it. The tree shaking will ensure the service is only included in the bundles where it is used.
Use the providers array in a component if the service only needs to be provided in the component and its nested children. (For service isolation at the component level or if you need multiple instances of the service per component.)
Don't use the providers array in a module (this is old syntax and it no longer recommended)
Use providedIn='lazymodule' if you want to limit access to a service to a particular lazy loaded…