How to target on the specif item under the nested loop
<ul #parents *ngFor="let parent of parents">
<li #child *ngFor="let child of parents.childGroup"> {{child.name}} </li>
<ul>
Ts File
Asper my code my target is parents[5].child[0] , but its working as child parents[0].child[0]
@ViewChildren('parents') parents : QueryList<ElementRef>
@ViewChildren('child') child: QueryList<ElementRef>
this.parents.forEach((item, index) => {
if (index === 5 ) {
(this.child.find( (item , index) => index === 0 ).nativeElement as HTMLElement).click();
}
});
Each parent has own children, Here target calculated based on all child index
How to solve this problem?