Forum Academy Marketplace Showcase Pricing Features

Angular Nebular

I’m new to angular i need your help to patch value of multiple checkbox angular nebular theme
and update value in database
this is .html file
<div class=" ml-md-2 mr-md-4" *ngFor="let site of sites; let i=index" >
<nb-checkbox [value]="site.id" formControlName="siteDestination (checkedChange)="onChange($event)" >{{site.name}} </nb-checkbox>
</div>

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 click 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