HTMLElement properties return undefined — Angular

I am writing an Angular component that has a QueryList of HTMLElements and when iterating over the list, I am able to log each element to console. However when I try to access a property of the element it returns undefined. This is true for every property of the element. I have made sure that the elements are actually present in the list, but they are present as objects with the property ‘nativeElement’ Here is the console

Thank you for considering this.


@ViewChildren('element') elements !: QueryList<HTMLElement>

function()
  {
    this.elements.forEach(function(element) {
      console.log(element) //prints object with correct data to console
      console.log(element.className) //prints undefined
    })
  }

18 thoughts on “HTMLElement properties return undefined — Angular”

  1. 364903 782782Directories such given that the Yellow Websites want not list them, so unlisted numbers strength sometimes be alive a lot more harm than financial assistance. 389943

    Reply

Leave a Comment