Is there a way to have two buttons on a toast and a handler assigned to each? For example I want to ask the user a question and have two buttons yes/no, depending on which one is clicked… something different would happen.
Basically what I’m trying to do is ask if users are enjoying my app…
If they click Yes, show the rating dialog.
If they click No, show a feedback dialog.
the way it presents itself though should be in the form of a Toast, slides up from the bottom with text “Are you enjoying the app?” and a yes and no button.
Clone the code of a toast conponent and adjust
Toast out of the box only has one button
A component which add an ion-footer
then?
Please, provide a “X” button to close the alert :'D
How can I clone the component?
You take the code
Copy it
Rename it
Amend it to have two buttons
Use it
Ay buddy did u end up doing it? Because I’m looking for smth similar rn
You can add more than one button using ionic 4
async presentToastWithOptions() {
const toast = await this.toastController.create({
header: 'Toast header',
message: 'Click to Close',
position: 'top',
buttons: [
{
side: 'start',
icon: 'star',
text: 'Favorite',
handler: () => {
console.log('Favorite clicked');
}
}, {
text: 'Done',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
]
});
toast.present();
}
1 Like