I have an viewport: ElementRef
object in a component, which I can log and see values for all of its properties. I can see that there is an array of children
of length 3, and I need to access children[1]
.
While logging the value of viewport
allows me to see all of its properties, when I try to access viewport.nativeElement
I get undefined. Therefore when I try to access viewport.nativeElement.children[1]
I get the error:
Cannot read property 'children' of undefined
I am trying to figure out:
- Why the
nativeElement
value is undefined when I can clearly see that the ElementRef has a value - If there is a different way to access properties such as
getBoundingClientRect()
without usingnativeElement