Get vales from Ion-checkbox


Hey ! I have a JSON URL from which some data is coming, I am getting that data in Checkbox. The problem is that how to get data (values selected) from ion-checkbox ?


Use ngModel for that maybe, it’s what you want ?

Checkbox doc with ngModel


@Dlazzy i am using ngModel but its not getting the values of all selected checkboxes. Moreover how can i restore multiple values in 1 ngModel.


@pendora7 Can you show some code ?


@Dlazzy here i want to get value of every selected checkbox…
54 PM


But for now your code does not add already ‘selected’ checkbox ?


modify your ion-checkbox like this:

<ion-checkbox *ngIf="tost.qotext != ''" (ionChange)="getChanged(tost.qotext)" ></ion-checkbox>

And then in your ts file:

export class DemoPage{
  selectedCheckbox: any;
  constructor() {
  this.selectedCheckbox = {};
      this.selectedCheckbox[e] = true;
      this.selectedCheckbox[e] = false;

You’ll get all your selected checkbox in json with true value.( check variable this.selectedCheckbox)