Browse Source

added direct value binding to value boxes to ommit forced ngModel

Warafear 1 năm trước cách đây
mục cha
commit
df370d66df

+ 1 - 1
src/app/shared-components/value-box/value-box.component.html

@@ -1,7 +1,7 @@
 <div class="container">
   @if(isInput){
   <input
-    [(ngModel)]="value"
+    [(ngModel)]="data"
     (ngModelChange)="onChange($event)"
     (blur)="onTouched()"
     id="input"

+ 4 - 3
src/app/shared-components/value-box/value-box.component.ts

@@ -14,15 +14,16 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
   ],
 })
 export class ValueBoxComponent {
-  public value: any;
+  public data: any;
+  @Input() value: any;
   @Input() label!: string;
   @Input() isInput: boolean = false;
 
   onChange: any = () => {};
   onTouched: any = () => {};
 
-  writeValue(value: any): void {
-    this.value = value;
+  writeValue(data: any): void {
+    this.data = data;
   }
 
   registerOnChange(fn: any): void {