2
votes

I have an app in Ionic 5 using Angular in which I need to programmatically navigate from the current page to the previous page. I tried using:

this._location.back();

and it works but doesn't triggers the back navigation animation like when you navigate with <ion-back-button>, it just switches pages. So the question is how can you programmatically navigate back on an Ionic 5 app with Angular, in a way similar to what <ion-back-button> does?

2

2 Answers

9
votes
constructor(private navController: NavController){}

 this.navController.back();
4
votes

The previous answer is correct. As stated by the developers of Ionic here:

https://github.com/ionic-team/ionic-framework/issues/20448#issuecomment-586288155

it is still save to use the NavController (in combination with angular routing) and this will not be deprecated in future. The documentation on this is missing.