Skip to content

Commit

Permalink
fix: fix ngmodel duplicated issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 15, 2020
1 parent 0890ae5 commit 8bfd9eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<span class="title">{{checklist?.title}}</span>
<span *ngIf="checklist.description" class="description"> {{checklist.description}}</span>
</mat-checkbox>
<component-todo name="todo" ngDefaultControl [disableInput]="true" [(ngModel)]="checklist.subitems" (ngModelChange)="changeTodo($event, i)"></component-todo>
<component-todo name="todo" [disableInput]="true" [toDos]="checklist.subitems"></component-todo>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { LedgeStorageService } from '../../services/ledge-storage.service';
templateUrl: './component-todo.component.html',
styleUrls: ['./component-todo.component.scss'],
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => ComponentTodoComponent),
multi: true
}
]
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => ComponentTodoComponent),
multi: true
}
]
})
export class ComponentTodoComponent implements OnInit, OnDestroy, ControlValueAccessor {
@Input() form: FormGroup;
Expand All @@ -28,8 +28,11 @@ export class ComponentTodoComponent implements OnInit, OnDestroy, ControlValueAc
private unsubscribe = new Subject<void>();
private disabled = false;

onChange(change: any) {}
onTouched() {}
onChange(change: any) {
}

onTouched() {
}

constructor(private formBuilder: FormBuilder, private storage: LedgeStorageService) {
}
Expand Down Expand Up @@ -85,6 +88,8 @@ export class ComponentTodoComponent implements OnInit, OnDestroy, ControlValueAc
}

writeValue(value: any): void {
this.toDos = value;
if (value !== null && value !== undefined) {
this.toDos = value;
}
}
}

0 comments on commit 8bfd9eb

Please sign in to comment.