viewchild ng template code example
Example: viewchild for ngfor
<div *ngFor="let v of views">
<customcomponent #cmp></customcomponent>
</div>
-------------------------
import { ViewChildren, QueryList } from '@angular/core';
/** Get handle on cmp tags in the template */
@ViewChildren('cmp') components:QueryList<CustomComponent>; // or ElementRef if only need to grab element
ngAfterViewInit(){
// print array of CustomComponent objects
console.log(this.components.toArray());
}