I am struggling to see which one of the root
and the platform
options for providedIn
in a service is better.
Both make a service available in the whole application, the latter through a service and the former through the root injector. Any advice on this?
The difference between the root
and any
as per offical documentation :
root
: The application-level injector in most apps.
platform
: A special singleton platform injector shared by all applications on the page.
any
: The NgModule injector that receives the resolution.
For more details please refer this article .
Is a service considered a singleton in the case that I use any
? - No
To go back to the original question between root
& platform
, when using a single application in your project, it doesn't change anything performance wise.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.