How to default a ion-toggle to on?


#1

I am using an ion-toggle in Ionic 2, that I would like to default to on. I have tried the checked attribute, but it still defaults to off.

<ion-toggle [(ngModel)]="ratingModel.contact" formControlName="contact" id="contact" checked="true">Contactable</ion-toggle>

How do I default a ion-toggle to true or on?

Thanks


#2

SOLUTION:

In your Component code, set the ratingModel.contact property to true:

ratingModel.contact = true;