import { Directive , Input , ElementRef , AfterViewInit } from '@angular/core' ; example @ Directive ( { selector : '[Autofocus]' } ) export class AutofocusDirective implements AfterViewInit { @ Input ( ) Autofocus : boolean ; /**
     * Element to be autofocused
     */ private el : any ; constructor ( private elementRef ) { this . el = this . elementRef . nativeElement ; } /**
     * Focuses and Selects Element
     */ ngAfterViewInit ( ) { this . el . focus ( ) ; this . el . select ( ) ; } }