Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

How to properly use Hardware back button

$
0
0

I’m so desperately looking for an answer for this, please help.
I have three ionic pages, structure as follows

-features
 --home
 --request
   --new
   --old

And each pages has hardware back button listener inside the constructor function,
in new & old pages it simply change route back to home page,

this.platform.backButton.subscribeWithPriority(10, () => {
  this._router.navigate(['/features/home'])
});

in home.page.ts,

this.platform.backButton.subscribeWithPriority(10, () => {
  console.log(this.routerOutlet.canGoBack())
  if (!this.routerOutlet.canGoBack()) {
     App.exitApp()
  }
});

But my problem is when i put press back button on home page it doesn’t work but other two functions ( both new & old pages)working properly,

So then i put console.log inside every back button listener and once the app is on home page and once the back button is pressed it keeps calls the last visited page back button listener.

Any idea on what’s wrong here ?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>