import { AfterViewInit , Directive , ElementRef } from '@angular/core' ; @ Directive ( { selector : '[appFocusDefaultButton]' , } ) export class FocusDefaultButtonDirective implements AfterViewInit { constructor ( private _hostElement ) { } public ngAfterViewInit ( ) { ( this . _hostElement . nativeElement as HTMLElement ) . focus ( ) ; } }