title: How to set focus on a textbox in Angular
body: <p>How can I set focus on an element (such as a textbox) in a component's template? I have tried the below code.</p>
  
  <p>Html:</p>
  
  <pre><code>&lt;input #input id="name" type="text" [(ngModel)]="person.Name" class="form-control" /&gt;
  </code></pre>
  
  <p>Component:</p>
  
  <pre><code>import {Component, Input, Output, AfterContentInit, ContentChild,                   
      AfterViewChecked, AfterViewInit, ViewChild,ViewChildren} from 'angular2/core';
  
  export class AppComponent implements AfterViewInit,AfterViewChecked { 
      @ViewChildren('input') vc;
  
      ngAfterViewInit() {            
          this.vc.first.nativeElement.focus();
      }
  </code></pre>
  
  <p>But it's giving an error.</p>