7

As we know In ionic 4 they replaced push and pop fucntionality with navigateForward and navigateBack. But by using this method i am not able to get back button in status bar. Any one is having any idea how to implement back button in ionic 4?

2

3 Answers 3

8

In your HTML, go to ion-toolbar tag inside ion-header tag and add the back button as

<ion-buttons slot="start">
   <ion-back-button></ion-back-button>
</ion-buttons>

This will add a back button at top left corner of your page and clicking on it will take you to previous route.

For more configs of back-button check the official Ionic v4.0 docs at https://ionicframework.com/docs/api/back-button/

Sign up to request clarification or add additional context in comments.

1 Comment

As it said in answers, don't forget defaultHref="home" attribute unless it won't show any button.
6

could you please trying to add back button in ion-toolbar .

 <ion-buttons slot="start">
      <ion-back-button defaultHref=""></ion-back-button>
  </ion-buttons>

Comments

6

Looks like there may be an issue where you need to supply a defaultHref attribute to get this to show up. On the surface this seems like annoying overhead, but I guess it does make you think about navigation paths for each page. Not ideal, but not horrible.

https://forum.ionicframework.com/t/ionic-4-back-button-angular/137866/18

2 Comments

that works but what about if we are not moving between pages and we're just opening a modal (with same url we had before open it)
fixed using this github.com/ionic-team/ionic-docs/blob/… but not exactly the same

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.