I am new to angular 4 and stuck with issue where page does not refresh if user clicks on back or forward browser button. query parameters in url changes as per history but page does not refreshes with previous results. For example /search?text="ret" and back button it becomes /search?text=ben&tab=doc.
Need to refresh the 'search' route on browser button click. Tried using Location popstate event which captures the click but not able to refresh the page.
Setting window.location.href works but it reloads the page. Can ngrx router-store could be a solution?
https://github.com/ngrx/platform/blob/v4.1.1/docs/router-store/api.md
As far as I understand, you do not need to refresh the page actually. That is all the thing about the Single Page Applications. Instead, try to change the page proactively in the location.onPopState
handler. You can do even router.navigate
there or parse popped query params, fetch and repopulate search results. You already know the new location, so act with this knowledge in-process.