angular 9 introduce new option for injectable decorator ProvidedIn in addition to the previous root
and module options, now we have two additional options
platform
, any
root— This tells Angular to provide the service in the application root level and the service will be created once (singleton service
) and provide the same instance in every module that injects the token.
any— Provides a unique instance in every module (including lazy
modules) that injects the token.
platform— Specifying providedIn: 'platform' makes the service
available in a special singleton platform injector that is shared by
all applications on the page.
a detailed look at Angular's 'root' and 'any' provider scopes