Ignore ionViewCanEnter on back navigation


#1

Hi,
I use the ionViewCanEnter event of ionic to enter a password before entering the page. This page navigates to other pages (nav push). And when I navigate back (back button) the user have to re-enter the password. But I do not want this. I want to ignore the ionViewCanEnter on back navigation.
Is there a method / value to check in ionViewCanEnter?

I want something like this:

ionViewCanEnter() {
  if (this.navCtrl.navigatedBack()) {
   return true;
  }
  this.reqeustPassword();
}

Or I have to check all children pages. What should I do?
Like if this.navCtrl.comesFrom(myChildPage) return true;


#2

One solution:

ionViewCanEnter() {
  let currentView = this.navCtrl.getActive();
  if (currentView.name === 'PreviousPage') {
    return this.requestPassword();
  }
  return true;
}

You also can check all childs from an array.

Other solutions are welcome.