【发布时间】:2018-11-09 07:52:34
【问题描述】:
对于我的应用程序,我想要一个类似 ngForOf (https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts) 的指令,但我不想从 Input() 中获取可迭代对象,而是从指令类中的行为主题中获取。
在 Host 类中使用 Behavior Subject 如下:
BehaviourSubject.subscribe((value) => {this.items = value})
<comp ngFor="let item of item"></comp>
不是一个选项。相反,我想在指令中开始订阅。
我想像这样使用指令:
<comp *ngFor></comp>
有什么想法可以完成这项工作吗? (来自 ngForCode 的更改)
【问题讨论】:
标签: angular directive angular2-directives