showing results for - "focuses on the input field automatically on page load angular"
Alexander
03 Mar 2017
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