How can I access the child elements (here:
) of @ViewChild()
in Angular 2+ without explicit declaration?
In template.htm
use ViewChildren
instead which gets all elements with same tag.
@ViewChildren('parent') parents: QueryList;
To convert those elements to array:
const arr = this.parent.toArray();
Choose first element:
const el = arr[0]
Access child html of first element: const innerHtml = el.nativeElement.innerHtml;