18 lines
407 B
TypeScript
18 lines
407 B
TypeScript
import { Directive, ElementRef, OnInit } from '@angular/core';
|
|
import { MatInput } from '@angular/material/input';
|
|
|
|
@Directive({
|
|
selector: '[matAutofocus]',
|
|
})
|
|
export class AutofocusDirective implements OnInit {
|
|
|
|
constructor(private element: ElementRef) { }
|
|
|
|
ngOnInit() {
|
|
setTimeout(() => {
|
|
this.element.nativeElement.focus();
|
|
this.element.nativeElement.scrollIntoView();
|
|
})
|
|
}
|
|
|
|
} |