With a structural directive, how would I get a hold of the (native) element the directive is on? With a normal directive, the ElementRef has it\'s nativeElement pointing to it -
When the structural directive is used on HTMLElement
, you will not get the reference to that element, as it is not rendered yet. The input text box
is not rendered yet when you are trying to access it in your code console.log(this.el.nativeElement); // template bindings comment
Please refer the link below to know how structural directives in Angular work. https://angular.io/guide/structural-directives#the-asterisk--prefix
So to get the reference of the element, you can use attribute directive
on the same element and do the things needed.