Richard
Richard

Reputation: 8945

How to default a ion-toggle to on?

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

Upvotes: 1

Views: 1232

Answers (1)

sebaferreras
sebaferreras

Reputation: 44659

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

ratingModel.contact = true;

Upvotes: 1

Related Questions