set autofocuse angularjs code example
Example 1: focuses on the input field automatically on page load angular
import { Directive, AfterViewInit, ElementRef } from '@angular/core';
@Directive({
selector: '[appAutofocus]'
})
export class AutofocusDirective implements AfterViewInit {
constructor(private el: ElementRef) {
}
ngAfterViewInit() {
this.el.nativeElement.focus();
}
}
Example 2: focuses on the input field automatically on page load angular
$ ng g directive autofocus