ProvideIn any和root之间有什么区别 [英] What is the difference between providedIn any and root
问题描述
在Angular 9中,可注入装饰器选项providedIn
具有一个名为any
的新值. root
和any
有什么区别?
In Angular 9 the injectable decorator option providedIn
has a new value called any
. What is the difference between root
and any
?
在使用any
的情况下,服务是否被视为单例?
Is a service considered a singleton in the case that I use any
?
@Injectable({providedIn: 'any'})
class UsefulService {
}
推荐答案
根据
有关更多详细信息,请参阅以下文章. For more details please refer this article. 在使用 Is a service considered a singleton in the case that I use 这篇关于ProvideIn any和root之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!root
:大多数应用程序中的应用程序级注入器.
root
: The application-level injector in most apps.platform
:所有人共享的特殊单例平台注射器
页面上的应用程序.platform
: A special singleton platform injector shared by all
applications on the page.any
:获得分辨率的NgModule注射器.any
: The NgModule injector that receives the resolution.any
的情况下,服务是否被视为单例? -否 any
? - No