doorman
doorman

Reputation: 16939

How to access nativeElement of div´s children

I am getting hold of a parent divs children and I am looping through these children. I need to access the nativeElement of each child.

 let children = Array.from(this.myParentDiv.nativeElement.children);
 for (let i = 0; i < children.length; i++) {
    console.log(children[i]); // Prints <div....
 console.log(children[i].nativeElement); // Prints undefined
}

How can I access the nativeElement of each children?

Upvotes: 1

Views: 4838

Answers (1)

El houcine bougarfaoui
El houcine bougarfaoui

Reputation: 37343

children[i] is the native element it self there is no property nativeElement specified in the dom.

and nativeElement is a property used by angular to access the native element regardless the platform (mobile , browser ..)

Upvotes: 4

Related Questions