1 import { AfterViewInit, Directive, ElementRef } from '@angular/core'
4 selector: '[myAutofocus]'
6 export class AutofocusDirective implements AfterViewInit {
7 constructor (private host: ElementRef) { }
10 const el = this.host.nativeElement as HTMLElement
12 el.focus({ preventScroll: true })