In my AngularJS application, I only need to save state changes in the browser history. Therefore, when I change the parameters of $ location, I use the replace () method.
For example, when I refer to / page 1, this is stored in the history. The center parameter is added automatically with replacement (), so it does not add a new history record:
$location.search('centre', hash).replace();
Each time I move the map, the "center" changes.
When I go to / page 2, a new history entry is created. When I move the map, the "center" changes.
The fact is that when I press the BACK button, I am going to / page 1, but I need to maintain the "center" as before, but it changes to what was saved along with the history record / page 1.
How can I fix this problem?
I tried to add:
$window.history.replaceState({}, '', $location.absUrl());
After replacing (), but does not work.
source
share