Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70432

Present a Toast after Clicking a Button in an Alert

$
0
0

@blandich wrote:

Hi,

So I need to present a toast after a clicking a button in my alert dialogue box, but I keep getting errors as I don’t know how to implement nested async methods. I tried the code below and I keep getting errors. Someone help me.

Thanks!

async addNewRoom(){
const alert = await this.alertController.create({
header: ‘Add New Room’,
message: ‘What type of room would you like to add?’,
buttons: [
{
text: ‘Common’,
handler: () => {
this.roomService.addGenericRoom(this.hcf_id).subscribe(e => {
console.log(e);
});
const toast = await this.toastController.create({
message: ‘A generic common room has been added.’,
duration: 2000,
showCloseButton: true
});
toast.present();
}
},
{
text: ‘Functional’,
handler: () => {
this.roomService.addGenericRoom(this.hcf_id).subscribe(e => {
console.log(e);
});
const toast = await this.toastController.create({
message: ‘A generic functional room has been added.’,
duration: 2000,
showCloseButton: true
});
toast.present();
}
},
{
text: ‘Cancel’,
role: ‘cancel’
}]
});
alert.present();
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70432

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>