I have implemented a button on my application that allows the user to navigate back to the previous page.
Here is how it's set up:
<button ng-click="goBack()">Go back</button>
$scope.goBack = function() {
$window.history.back();
}
However, I am looking to modify this functionality so that the button takes the user to the previous URL that is different from the current URL, rather than just the previously visited page (which may have the same URL as the current one).
For example:
- If I visit
/home
, then/products
, followed by another/products
, and then one more/products
- I would like the button to take me back to
/home
.