Imagine the user clicks on a link like this:
account/organisations/organisation1/news/21
After that, I use $location.path(url)
to redirect the user from the startpage (news/today
) to the specified page. But when the user tries to go back using the back button, they are taken back to news/today
instead of
account/organisations/organisation1/news/
I attempted to split the URL and manipulate the history in order to achieve the desired behavior:
var url = "account/organisations/Vereinsplaner/news/21".split("/");
var curUrl = "";
var part;
while(part = url.shift()){
curUrl = curUrl+"/"+part;
$location.url(curUrl);
$location.replace();
$window.history.pushState(null, 'any', $location.absUrl());
}
Context: This link is received through PushNotification in an Ionic App. When the user taps on it, they are redirected to the subpage but face issues navigating back due to lack of proper history.