monitor-dashboard/src/app/library/sharedComponents/input/focus.directive.ts

23 lines
455 B
TypeScript

import {Directive, HostListener, Input} from "@angular/core";
@Directive({
selector: '[focus-directive]',
})
export class FocusDirective {
@Input('formInput') formControl: any;
constructor() { }
@HostListener
('focus', ['$event.target'])
onFocus(target) {
this.formControl.markAsTouched({onlySelf: true});
}
@HostListener('blur', ['$event.target'])
onBlur(target) {
this.formControl.markAsUntouched({onlySelf: true});
}
}