Angular5 gets the url address of the previous page

problem description

in order to achieve a requirement, you need to obtain the url address of the previous page, but after checking it, we do not see what method Angular provides to obtain the url address of the previous page. Have you ever encountered similar problems and solutions

question background

actually needs to get url because what you are doing needs to implement such a requirement:
jumps from the second page of the list page to the details page, and you can return to the second page of the list page by returning the link.

to implement this requirement, I used ngRx to make a global State, to record the paging information of the list page when entering the details page from the list page. If the list page can get valid paging information, then use this paging information to call the back-end interface to get the second page data.
but there is a problem. When the user does not return to the list page from the details page, but to another page, the paging state still exists and will continue to be used the next time the user enters the list page. So I want to get the url, of the previous page to determine whether the paging status recorded in the global State should be used

Apr.09,2021
Just add page number information to the URL of the

list page (configure router)


add routing guards

Menu