viewchild for ngfor

Solutions on MaxInterview for viewchild for ngfor by the best coders in the world

showing results for - "viewchild for ngfor"
Lorcan
04 Aug 2018
1<div *ngFor="let v of views">
2    <customcomponent #cmp></customcomponent>
3</div>
4
5-------------------------
6
7import { ViewChildren, QueryList } from '@angular/core';
8
9/** Get handle on cmp tags in the template */
10@ViewChildren('cmp') components:QueryList<CustomComponent>; // or ElementRef if only need to grab element
11
12ngAfterViewInit(){
13    // print array of CustomComponent objects
14    console.log(this.components.toArray());
15}
16