Getting this backtrace on standard example code:
showToastWithCloseButton(){
const toast = this.toastCtrl.create({
message: 'Your files were successfully saved',
showCloseButton: true,
closeButtonText: 'Ok'
});
toast.present();
}
calling it from constructor in page
EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./RoomPage class RoomPage_Host - inline template:0:0
ORIGINAL EXCEPTION: TypeError: activeNav.getActive is not a function
ORIGINAL STACKTRACE:
TypeError: activeNav.getActive is not a function
at NavPortal.NavControllerBase._insert (/app2/build/js/app.bundle.js:60479:34)
at NavPortal.NavControllerBase.insertViews (/app2/build/js/app.bundle.js:60417:33)
at App.present (/app2/build/js/app.bundle.js:52397:29)
at Toast.present (/app2/build/js/app.bundle.js:74079:26)
at RoomPage.showToastWithCloseButton (/app2/build/js/app.bundle.js:240:15)
at new RoomPage (/app2/build/js/app.bundle.js:226:14)
at DebugAppView._View_RoomPage_Host0.createInternal (RoomPage.template.js:21:24)
at DebugAppView.AppView.create (/app2/build/js/app.bundle.js:31938:21)
at DebugAppView.create (/app2/build/js/app.bundle.js:32150:44)
at ComponentFactory.create (/app2/build/js/app.bundle.js:31008:36)
ERROR CONTEXT:
[object Object]
Hello! Thanks for opening an issue with us! In Ionic 2 you should use the lifecycle events, especially ionViewDidEnter for anything ui related, such as opening a toast. It is not recommend in Ionic 2, or Angular 2 that you put code in the constructor that does anything beyond initializing variables . The reason for this is that the constructor of a component is called long before the template of the component is ready and loaded into the dom. I would recommend taking a look at our lifecycle event docs here. Thanks for using Ionic!
@jgw96 thank you for quick reply and sorry for trashing great project by useless issues, next time will start from forum.
@theromis No problem at all! No issue is trash!
@jgw96 may be you can route me with this problem?
https://forum.ionicframework.com/t/ionic-2-beta-11-firefox-http-json-bug/60608
Most helpful comment
Hello! Thanks for opening an issue with us! In Ionic 2 you should use the lifecycle events, especially
ionViewDidEnterfor anything ui related, such as opening a toast. It is not recommend in Ionic 2, or Angular 2 that you put code in the constructor that does anything beyond initializing variables . The reason for this is that the constructor of a component is called long before the template of the component is ready and loaded into the dom. I would recommend taking a look at our lifecycle event docs here. Thanks for using Ionic!