3

I want my back button text (in Angular component) according to previous URL.

I have seen How to determine previous page URL in Angular? but what if the user refreshes the page? The previous URL info from router events is lost. Any work around except storing it in the local storage?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
artsnr
  • 952
  • 1
  • 10
  • 27
  • 3
    If a user hits refresh than you need to store the URL somewhere, either in client side: localstorage, cookies or in server side: database, files system. – Dima Gimburg Jul 30 '18 at 07:20
  • 1
    When you refresh your application the URL isn't lost. If it does in your application, please provide a [mcve]. –  Jul 30 '18 at 07:20
  • You can use HTML 5 `window.history` API to store route using `pushState` [See this](https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_replaceState%28%29.C2.A0method) – Shailesh Rathod Jul 30 '18 at 08:41
  • Check [This](https://community.wia.io/d/22-access-the-previous-route-in-your-angular-5-app) – Yazan Mehrez Jul 30 '18 at 12:12

0 Answers0