0

i have setup my route links like this

  1. matches screen

http://localhost:4200/#/nav/matches

  1. my profile

http://localhost:4200/#/nav/my-profile

  1. edit profile

http://localhost:4200/#/nav/edit-profile

  1. my photos

http://localhost:4200/#/nav/my-photos

  1. settings

http://localhost:4200/#/nav/settings

  1. my orders

http://localhost:4200/#/nav/my-orders

the problem iam facing is whenever i clicks the hardware back button after navigation through all these pages

app exits to goole default screen or some other url i searched before (like https://stackoverflow.com/) some times it comes to matches screen which is my default screen and exits ( navigating away from my site )

i want to go back to previous page of my application instead of exiting directly like

5 ==> 4==> 3 ==> 2 ==> 1 ==> exit

sinan
  • 133
  • 8

1 Answers1

1

The unexpected behaviour is because in my project to navigate to another routes we were using

    this.router.navigateByUrl(link, {replaceUrl: true});

this replaces history thanks to Angular 2 - replace history instead of pushing

then i changed that to

    this.router.navigateByUrl(link);

and the issue fixed

sinan
  • 133
  • 8
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 04 '23 at 17:25