I am working on a simple form with checkboxes and I need to send only the checked boxes to TypeScript. However, when I attempt to save the data by clicking the save button, I encounter an error message {test: undefined}
Below is the form layout:
<ion-content>
<ion-item *ngFor="let manager of managers; let i = index">
<ion-checkbox
color="primary"
[(ngModel)]="manager.id"
value="{{manager.id}}"
style="margin-right: 10px"
></ion-checkbox>
<ion-label>{{manager.name}}</ion-label>
</ion-item>
<ion-button (click)="save()">Save</ion-button>
</ion-content>
Here is the TypeScript code snippet:
manager:any;
constructor(private http: HttpClient) {}
save(){
let data ={
test: this.manager,
}
console.log(data);
}
Ultimately, my goal is to store the values of the checked checkboxes in an array in TypeScript.
Thank you for your help!