blob: 5bc8058d6a63a8ab394f239e1837f67739ea416b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import {Directive, ElementRef, HostListener} from '@angular/core';
@Directive({
selector: '[appRemoveSpace]'
})
export class RemoveSpaceDirective {
constructor(private _el: ElementRef) { }
@HostListener('textarea', ['$event']) onInputChange(event) {
const initialValue = this._el.nativeElement.value;
this._el.nativeElement.value = initialValue.toString().trim();
if ( initialValue !== this._el.nativeElement.value) {
event.stopPropagation();
}
}
}
|