projects/rebirth-ng/src/lib/common/auto-focus.directive.ts
selector | [reAutoFocus] |
Methods |
Inputs |
constructor(elementRef: ElementRef)
|
||||||
Parameters :
|
reAutoFocus
|
Type: |
ngAfterViewInit |
ngAfterViewInit()
|
Returns :
void
|
import { Directive, Input, ElementRef, AfterViewInit } from '@angular/core';
@Directive({
selector: '[reAutoFocus]',
})
export class AutoFocusDirective implements AfterViewInit {
@Input('reAutoFocus') autoFocus: boolean;
constructor(private elementRef: ElementRef) {
}
ngAfterViewInit(): void {
if (this.autoFocus && this.elementRef.nativeElement.focus) {
this.elementRef.nativeElement.focus();
}
}
}