Navigating from back button


#1

Is there a way by which i can identify in, for instance, “ionViewDidEnter()”, that im coming back to the page after having hit the back button?
Thanks

[Update: more info]
Given the following sequence, how can I in step 4) identify that im entering page_1 due to a back button action?

  1. user enters page_1.
  2. from page_1, the user navigates to page_2 (via navCtrl.push() ).
  3. in page_2, the user clicks on the back button.
  4. user enters back to page_1.

#2

Normally you should occupy “status bar” in a native way which allows you to do this (I imagine you are already occupying it). What the status bar does is that it keeps the routes in memory where you go sailing. Now if you have it through an ionic-button which you created, you must indicate the path of the page you want to access which would be something like this.navCtrl.push (‘MyPage’);


#3

I updated the original post.


#4

This thing is happening because from next time Page 1 is coming from Navigation Stack. In that case, you can detect it by using ionViewCanEnter

page_1.ts

ionViewCanEnter() {
  console.log('IonViewCanEnter Page_1Page');
}

Explanation:
When any page is coming from Navigation Stack, then neither constructor nor ionViewDidLoad gets fired again. But IonViewCanEnter is an authentication life-cycle which get fired every time the page loads.

Please let us know if this works.