import { Directive , ElementRef , AfterViewInit } from '@angular/core' ; @ Directive ( { selector : '[autoFocus]' , } ) export class AutoFocusDirective implements AfterViewInit { constructor ( private _element ) { } ngAfterViewInit ( ) { this . _element . nativeElement . focus ( ) ; } }