access local variable within *ngIf
问题 I have a primeng (angular 2) dialog with a dropdown. I want to set focus to the dropdown when the dialog shows. The problem appears to be that my div is rendered conditionally. My code: <p-dialog (onShow)="fe.applyFocus()"> <div *ngIf="selectedItem"> <button pButton type="button" (click)="fe.applyFocus()" label="Focus"></button> <p-dropdown #fe id="reason" [options]="reasonSelects" [(ngModel)]="selectedReason" ></p-dropdown> </div> </p-dialog> In this code the button works fine, but the