我有许多通过*ngFor创建的子组件的实例。我想使用一些选择方法(我从parent中选择一个)。我怎么能做到这一点?
因为ViewChild不工作(我有很多组件)。此外,ViewChildren也无法正常工作。因为我是在一段时间后动态创建的,而ViewChildren的长度为0。
谢谢你提供的任何信息。
举个例子。_schedCompntnsArr的长度为0(但在第4页上,我有4个组件)。
directives: [
SchedulerComponent
],
@ViewChildren(SchedulerComponent) schedCompntsList: QueryList<SchedulerComponent>;
ngAfterViewInit() {
this._schedCompntnsArr = this.schedCompntsList.toArray();
}https://stackoverflow.com/questions/38269161
复制相似问题