我在Bootstrap中定义了@Injectable
服务.我希望在不使用构造函数注入的情况下获得服务的实例.我try 使用ReflectiveInjector.resolveAndCreate
,但这似乎创建了一个新实例.
我try 这样做的原因是我有一个由许多组件派生的基本组件.现在我需要访问服务,但我不想将其添加到ctor,因为我不想在所有派生组件上注入该服务.
TLDR:我需要ServiceLocator.GetInstance<T>()
分
UPDATE: RC5+的更新代码:Storing injector instance for use in components