title: access local variable within *ngIf
body: <p>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 <code>div</code> is rendered conditionally.</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;p-dialog (onShow)="fe.applyFocus()"&gt;
    &lt;div *ngIf="selectedItem"&gt;
      &lt;button pButton type="button" (click)="fe.applyFocus()" label="Focus"&gt;&lt;/button&gt;
      &lt;p-dropdown #fe id="reason" [options]="reasonSelects" [(ngModel)]="selectedReason" &gt;&lt;/p-dropdown&gt;
    &lt;/div&gt;
  &lt;/p-dialog&gt;
  </code></pre>
  
  <p>In this code the button works fine, but the onShow() (outside the <code>*ngIf</code> div) tells me <code>fe</code> is undefined.</p>
  
  <p>How can I access the local variable inside the <code>*ngIf</code>?</p>