Answers for "viewchild for ngfor"

0

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());
}
Posted by: Guest on January-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language