Monday, 2 May 2022

Angular 8 retrieve list of elements from HTML

https://stackoverflow.com/questions/48562310/use-viewchild-for-dynamic-elements-angular-2-ionic-2


 <div *ngFor="let name of title;let i = index;" #slides>

    <ion-slides  id="something">
        //some code
    </ion-slides>
</div

Component.ts

@ViewChildren("slides") private slides: QueryList<ElementRef>;
  ....

ngAfterViewInit(): void {
    this.slides.changes.subscribe(() => console.log(this.slides));
}

No comments:

Post a Comment