1 import { Directive, EventEmitter, HostListener, Input, OnInit } from '@angular/core';
2 import { NgControl } from '@angular/forms';
4 import { FormatterService } from '../services/formatter.service';
9 export class IopsDirective implements OnInit {
11 ngDataReady: EventEmitter<any>;
13 constructor(private formatter: FormatterService, private ngControl: NgControl) {}
15 setValue(value: string): void {
16 const iops = this.formatter.toIops(value);
17 this.ngControl.control.setValue(`${iops} IOPS`);
21 this.setValue(this.ngControl.value);
22 if (this.ngDataReady) {
23 this.ngDataReady.subscribe(() => this.setValue(this.ngControl.value));
27 @HostListener('blur', ['$event.target.value'])
28 onUpdate(value: string) {