Ionic 3 - this.navCtrl.last() works in development mode but dosen't work in production build in android

  • In my application, there are number of pages which redirects to one common page.
  • Now in that common page I use this.navCtrl.last() for returning back to the page it came from.
  • It works properly in development mode as this.navCtrl.last() gives us last page name.
  • But same functionality not working in production build, it doesn’t redirect to previous page.

in constructor I use

this.page = this.navCtrl.last().name;

and on click of button in the common page it redirects to the page from where it came from
so on button click I use

this.navCtrl.push(this.page);

For above scenario page redirects nowhere on click of button in production build, I just want the same results as in development mode.

I would suggest rethinking this design. You can’t ever rely on class names as strings in an Ionic app, and that includes page/component classes. Why aren’t you just using pop() here?