You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
529 B

import { Directive, ElementRef, Input } from '@angular/core';
@Directive({
selector: '[focus]'
})
export class FocusDirective {
constructor(
private _elementRef: ElementRef
) { }
ngAfterViewInit(): void {
if (this._value != false) {
setTimeout(() => this._elementRef.nativeElement.focus());
}
}
@Input()
public set focus(value: boolean) {
if ((this._value = value) != false) {
setTimeout(() => this._elementRef.nativeElement.focus());
}
};
private _value: boolean = null;
}