]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/trim.directive.ts
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / directives / trim.directive.ts
CommitLineData
92f5a8d4
TL
1import { Directive, HostListener } from '@angular/core';
2import { NgControl } from '@angular/forms';
3
f67539c2 4import _ from 'lodash';
92f5a8d4
TL
5
6@Directive({
7 selector: '[cdTrim]'
8})
9export class TrimDirective {
10 constructor(private ngControl: NgControl) {}
11
12 @HostListener('input', ['$event.target.value'])
9f95a23c 13 onInput(value: string) {
92f5a8d4
TL
14 this.setValue(value);
15 }
16
17 setValue(value: string): void {
18 value = _.isString(value) ? value.trim() : value;
19 this.ngControl.control.setValue(value);
20 }
21}