OnInit,
Output
} from '@angular/core';
-import { NgControl } from '@angular/forms';
+import { NgControl, Validators } from '@angular/forms';
import _ from 'lodash';
setValue(value: string) {
if (/^[\d.]+$/.test(value)) {
value += this.defaultUnit || 'm';
+ } else {
+ if (value) {
+ this.control.control.setValue(value);
+ this.control.control.addValidators(Validators.pattern(/^[a-zA-Z\d. ]+$/));
+ this.control.control.updateValueAndValidity();
+ }
}
const size = this.formatter.toBytes(value);
const roundedSize = this.round(size);