title: Setting focus in text box when Kendo Window is opened
body: <p><a href="https://plnkr.co/edit/uorYAlr7iGvSn9CZuSsC?p=preview" rel="nofollow noreferrer">In this plunk</a> I'm trying to set the focus on the first field of a <code>kendo-window</code> when it is opened (click on the button to open the window). I declared the field with <code>ViewChild</code>, however it's <code>undefined</code> when the window is opened as when the program starts the window hasn't been created yet. </p>
  
  <p>When I attempt to set the focus, I get <code>Cannot read property 'nativeElement' of undefined</code> (see the console).</p>
  
  <p>Is it possible to reference a variable with <code>ViewChild</code> after the window is created? How to set the focus on the first field when the window is opened?</p>
  
  <pre><code>@Component({
    selector: 'my-app',
    template: `
      &lt;div class="example-wrapper"&gt;
      &lt;button kendoButton (click)="open()"&gt;Open window&lt;/button&gt;
      &lt;kendo-window title="Some title" *ngIf="opened" (close)="close()" [width]="450"&gt;
  
          &lt;form class="k-form"&gt;
              &lt;input kendoTextBox type="text" name="userId" placeholder="User ID"
                   #userId class="k-textbox" autofocus&gt;
              &lt;input kendoTextBox type="text" name="firstName" placeholder="First Name" 
                   #firstName class="k-textbox"&gt;
          &lt;/form&gt;
  
          &lt;/kendo-window&gt;
        &lt;/div&gt;
      `
  })
  export class AppComponent {
      public opened = false;
  
      @ViewChild('userId') uid: ElementRef;
  
      open(){
        this.opened = true;
        this.uid.nativeElement.focus();
      }
  
      close(){
        this.opened = false;
      }
  
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Changed the PLUNK to show that <code>autofocus</code> does not work the second time the window is opened.</p>