@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