Ion-toggle Question

Does ion-toggle support (click) event? currently I see it only supports (ionChange). This is a not working for my case because I have an array of ion-toggles. Depend on the value of current ion-toggle, I need to toggle other ion-toggle. As soon as I change the value of an ion-toggle, because of ionChange triggers when there is change, therefor it will try to toggle other ion-toggles. If this component support (click) event, I will not encounter this situation. Is there a work around if ion-toggle only supports (ionChange).

I have checked out documentation on ion-toggle, I do not see any other events supported beside (ionChange).

Thank you very much.

Hello @HoangTDI, I don’t know what you are trying to do but in one of my apps, I have an array of some strings which I load using ngFor and then create toggle buttons against every array element and in this case (ionChange) serves the purpose. Let me know in some detail or provide some sample code so that I can guide you in a better way.

  <ion-label>Toggle 1</ion-label>
  <ion-toggle (ionChange)="toggleClicked("toggle1Clicked")"></ion-toggle>

  <ion-label>Toggle 2</ion-label>
  <ion-toggle (ionChange)="toggleClicked("toggle2Clicked")"></ion-toggle>

Now you can handle toggleClicked() function in your ts file and check which toggle has been clicked so that you can do respective action. Please let me know if you have any confusion.

Thank you sir very much.

1 Like

You’re welcome :slight_smile: