1 import { Directive, HostListener } from '@angular/core';
2 import { NgControl } from '@angular/forms';
4 import * as _ from 'lodash';
9 export class TrimDirective {
10 constructor(private ngControl: NgControl) {}
12 @HostListener('input', ['$event.target.value'])
17 setValue(value: string): void {
18 value = _.isString(value) ? value.trim() : value;
19 this.ngControl.control.setValue(value);