|
@@ -0,0 +1,35 @@
|
|
|
+import { Component, forwardRef, Input } from '@angular/core';
|
|
|
+import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'value-box',
|
|
|
+ templateUrl: './value-box.component.html',
|
|
|
+ styleUrl: './value-box.component.scss',
|
|
|
+ providers: [
|
|
|
+ {
|
|
|
+ provide: NG_VALUE_ACCESSOR,
|
|
|
+ useExisting: forwardRef(() => ValueBoxComponent),
|
|
|
+ multi: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+})
|
|
|
+export class ValueBoxComponent {
|
|
|
+ public value: any;
|
|
|
+ @Input() label!: string;
|
|
|
+ @Input() isInput: boolean = false;
|
|
|
+
|
|
|
+ onChange: any = () => {};
|
|
|
+ onTouched: any = () => {};
|
|
|
+
|
|
|
+ writeValue(value: any): void {
|
|
|
+ this.value = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ registerOnChange(fn: any): void {
|
|
|
+ this.onChange = fn;
|
|
|
+ }
|
|
|
+
|
|
|
+ registerOnTouched(fn: any): void {
|
|
|
+ this.onTouched = fn;
|
|
|
+ }
|
|
|
+}
|