为什么@SkipSelf装饰器无法像jectort.get(Foo,...,InjectFlags.SkipSelf)一样工作?

时间:2019-07-18 13:41:27

标签: angular dependency-injection

我陷入了意料之外的事情。

我处于这种情况下,我的childComponent需要注入SomeService并提供自己的SomeService。 如果我在父级@SkipSelf()上使用SomeService装饰器,则一切正常。

但是我想使构造函数签名尽可能简单(因为ChildComponent将是实际实现中的基类); 因此,我尝试改用Injector,如下所示:

this.parentService = injector.get(SomeService, undefined, InjectFlags.SkipSelf);

通过使用注入器,我可以获得ChildComponent提供的相同服务,有什么线索吗?我是否期望这些标志以错误的方式工作?

这是我正在尝试做的一个非常简单的示例 https://stackblitz.com/edit/angular-xhfbel

喷射器文档 https://angular.io/api/core/Injector#get

谢谢大家

0 个答案:

没有答案
相关问题