Check check-box programmatically in Ionic2 TypeScript Application


#1

I’m trying programmatically check check-box in Ionic2 Type Script Application, here is my page.ts this.checkCheckBox(); with isChecked: boolean; variable from constructor load by default:

  checkCheckBox()
  {
    this.isChecked = true;
  }

and page.html:

  <ion-item>
    <ion-label>Build</ion-label>
    <ion-checkbox [checked]="!isChecked" [(ngModel)]="build" ></ion-checkbox>
  </ion-item>

not sure what is wrong here, it is not checked


#2

You have the check box set to be checked when isChecked is false.

The other issue is that [checked] and [(ngModel)] don’t play well together, and so you should only have one of them.


#3

@SigmundFroyd Thank you