我想在一次 ng for 后访问组件的所有 viewChildren,例如:
<component #item *ngFor="let item of items" [parameter1]="item.parameter1" [parameter2]="item.parameter2"></component>
现在,我有一个像这样的 ViewChildren:
@ViewChildren('item') item: QueryList<Item>
但是当我console.log他时,它只出现一个,我想获得每个ngFor的引用
最佳答案
试试这个.toArray,它有效:
@ViewChildren('item') item;
this.item.toArray()
关于javascript - NgFor 之后访问 ViewChildren 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47461819/