Hi there.
I have this code, to call a ionic 2 toast and loading emitting an event.
But the matter is that when I call the loading and then toast, just one appears and freeze the view.
Someone can help me to solve this please?
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = LoginPage;
loading: Loading;
toast: Toast;
constructor(
platform: Platform,
private menu: MenuController,
private events: Events
) {
platform.ready().then(() => {
StatusBar.styleDefault();
this.listenToEvents();
});
}
openPage(page:any) {
this.rootPage = page;
this.menu.close();
}
showLoading() {
this.loading = Loading.create({
content: “Cargando…”,
dismissOnPageChange: true
});
this.nav.present(this.loading);
}
showToast(message: string){
this.toast = Toast.create({
message: message,
duration: 3000
});
this.nav.present(this.toast);
}
hideLoading(){
if(this.loading instanceof Loading){
this.loading.dismiss();
}
}
hideToast(){
if (this.toast instanceof Toast){
this.toast.dismiss();
}
}
listenToEvents() {
this.events.subscribe('loading:show', () => {
this.showLoading();
});
this.events.subscribe('loading:hide', () => {
this.hideLoading();
});
this.events.subscribe('toast', (message:string) => {
this.showToast(message);
});
}
}
ionicBootstrap(MyApp, [CustomHttp, Auth]);