I'm new to angular i need your help to patch value of multiple checkbox angular nebular theme
<nb-checkbox [value]="site.id" formControlName="siteDestination (checkedChange)="onChange($event)" > </nb-checkbox>
this is .ts file
sites=[{id:1,name:"lcv"},{id:2,name:"wcv"},{id:3,name:"hcv"}]
onChange(event){`
const destArray: FormArray = this.destinationForm.get('siteDestination') as FormArray;
let checked=event.target.checked;
if (checked) {
destArray.push(new FormControl(event.target.value));
} else {
let i: number = 0;
destArray.controls.forEach((item: FormControl) => {
if (item.value == event.target.value) {
destArray.removeAt(i);
return;
}
i++;
});
}
}
when go to edit it indicate all as selected. when i unchecked console indicate as
"Cannot read property 'checked' of undefined"
I am expect correction or future implementation of this
Aucun commentaire:
Enregistrer un commentaire