Answers for "focuses on the input field automatically on page load angular"

0

focuses on the input field automatically on page load angular

$ ng g directive autofocus
Posted by: Guest on August-17-2020
0

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();
  }
 
}
Posted by: Guest on August-17-2020

Code answers related to "focuses on the input field automatically on page load angular"

Code answers related to "Javascript"

Browse Popular Code Answers by Language