Issue
I woul like to access all the viewChildren after one ng for to a component, for example:
<component #item *ngFor="let item of items" [parameter1]="item.parameter1" [parameter2]="item.parameter2"></component>
Now, i have a ViewChildren like this:
@ViewChildren('item') item: QueryList<Item>
but when i console.log him, it only appears one and i would like to have the reference of every of the ngFor
Solution
You can subscribe to changes to get notified when the queried elements change:
ngAfterViewInit() {
console.log(this.item.toArray());
this.item.changes.subscribe(() => {
console.log(this.item.toArray());
});
}
Answered By - Günter Zöchbauer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.