I'm looking to implement multiple toasts in Ionic framework v4, but I'm not sure how to go about coding it.
I attempted to implement multiple toasts in Ionic v3, but it didn't meet my requirements.
import { Component, OnInit } from '@angular/core';
import { ToastController } from '@ionic/angular';
@Component({
selector: 'gd-toast',
templateUrl: './gd-toast.component.html',
styleUrls: ['./gd-toast.component.scss'],
})
export class GdToastComponent implements OnInit {
constructor(public toastController: ToastController){}
ngOnInit() {
}
public toastMsgs: any = [];
async presentToast(msg) {
this.toastMsgs.push(msg);
const toast = await this.toastController.create({
message: this.toastMsgs.toString().split(",").join("\n"),
position: 'bottom',
showCloseButton: true,
closeButtonText: 'Ok',
// duration: 3000,
});
toast.present();
toast.onDidDismiss().then(() => {
this.toastMsgs = [];
});
}
}