Answer the question
In order to leave comments, you need to log in
What is providedIn in the Injectable decorator?
I didn’t understand a little what kind of parameter providedIn is in Injectable and in what cases should it be used?
Answer the question
In order to leave comments, you need to log in
Injectable classes can be included in the root of the application or in submodules (for lazy loading, for example). There are other ways.
For example, you include Injectable classes at the root and declare them in the providers group of the @NgModule decorator, and you end up with a sheet of a bunch of services. Or you declare providedIn: root in the @Injectable decorator itself, and you don't need to declare them in @NgModule anymore.
https://angular.io/guide/hierarchical-dependency-i...
https://angular.io/api/core/Injectable#providedIn
https://angular.io/guide/singleton-services
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question