I am trying to define a template variable for an element and use its hidden attribute to determine if the element is actually present in the DOM and then displays another element on it. But if there is a structural directive, the template variable does not seem to return a value.
<hr class="divider" *ngIf="true" #divi> <div *ngIf="showResendWelcomeEmailButton"> <a *wpHasAnyPermission="[{'something': true}]" #resendEmailBtn> Resend Welcome Email </a> </div> <div class="pull-right"> <a #editAccountBtn>Edit Account Details</a> </div> rbtn: {{resendEmailBtn?.hidden}} ebtn: {{editAccountBtn?.hidden}} dline: {{divi?.hidden}}
Output
rbtn: ebtn: false dline:
As you can see, both template variables on elements containing ngIf and wpHasAnyPermission do not return values.
Ultimately, I want to use resendEmailBtn and editAccountBtn in ngIf for hr to select a separator display.
What is the best way to solve this problem? I want to avoid using component code. Try to solve this with HTML.
source share