소스 검색

added direct value binding to value boxes to ommit forced ngModel

Warafear 1 년 전
부모
커밋
df370d66df
2개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      src/app/shared-components/value-box/value-box.component.html
  2. 4 3
      src/app/shared-components/value-box/value-box.component.ts

+ 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 {