What is the difference between providedIn any and root

I think provided answers are not really clear. However, @jkonst, @schrödingcöder and @Bruce are correct in the comment.

For any one sent here by Google,

any doesn't Provides a unique instance in every module. (should say only in every shared module)

Which means one instance in every inject scope

from https://angular.io/guide/providers

With providedIn: 'any', all eagerly loaded modules share a singleton instance; however, lazy loaded modules each get their own unique instance, as shown in the following diagram.

diagram


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


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