1import { Directive, AfterViewInit, ElementRef } from '@angular/core';
2
3@Directive({
4 selector: '[appAutofocus]'
5})
6export class AutofocusDirective implements AfterViewInit {
7
8 constructor(private el: ElementRef) {
9 }
10
11 ngAfterViewInit() {
12 this.el.nativeElement.focus();
13 }
14
15}
16