Ionic 4 - check if can go back


I’m looking for a way to redirect a user back after a click on a button if said back exists, and to a specific route otherwise.

I need to add a condition to my code, but Idon’t seem to find a way.

  goback() {
    if("something") {
    else {

In Ionic 3 we had canGoBack() function… Any idea for Ionic 4?


Received a very clear answer on StackOverflow :slight_smile:

[EDIT] doesn’t work for me yet, will update if I find a good solution

JerryBels, good day! Any update of this topic ? I can not find any solution.

Hi, sorry to disappoint but I never had thetime so I ended up using a workaround to what I needed to do… Good luck!

JerryBels, what workaround do you use?

I mean I avoided having to detect this by using a workaround for the reason I needed it in the first place. Changed my architecture a bit.