When working with my Angular directive, I encountered an issue where I was trying to access the input elements within a form that I injected as a host element. However, it seems like the code is running before the form (host) has been rendered, meaning that the input elements have not yet been created.
constructor(private elementRef: ElementRef,private renderer: Renderer2) {
let formElement = <HTMLFormElement>elementRef.nativeElement;
let inputFields = console.log(formElement.getElementsByTagName("input")); //This returns nothing
console.log(formElement.getElementsByTagName("input")); //Although this works, it only logs lazy loaded inputs
I am wondering if there is a way to delay executing this logic until after the host view is fully ready. Perhaps something similar to an @HostListener
for a ready event.