Angular 2:从ViewContainerRef获取指令

时间:2017-02-23 12:01:10

标签: angular typescript

让我们假设我有一个指令“Lol”。 在组件中,我可以查询使用Lol注释的内容子项:

@ContentChildren(Lol)
private myLols: QueryList<Lol>;

很好,当我在他们旁边做一些组件创建魔术时,我可以使用ViewContainerRef:

@ContentChildren(Lol, {read: ViewContainerRef})
private myLols: QueryList<ViewContainerRef>;

我想做的是:

  • 在每个带有lol标注的元素旁边创建一个组件

  • 将组件绑定到Lol指令的输入。

所以我需要ViewContainerRef以及Directive实例。有没有办法从指令类型中获取ViewContainerRef,反之亦然?

0 个答案:

没有答案