0
用户点击例如此链接:account/organisations/organisation1/news/21
我然后通过$location.path(url)
从起始页(news/today
)到特定的页面重定向用户。如果现在用户按下后退按钮等他回来给news/today
但应该被重定向到account/organisations/organisation1/news/
我企图分裂URL和推动国家“假”的历史不起作用:
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());
}
背景:我通过PushNotification在Ionic App中获得此链接。当用户点击它时,他将被重定向到子页面,但不能返回(因为没有历史记录可用)。
如果你使用$位置的原因离子使用它的用户界面,路由器,首选方法是$ state.go()重定向和登记之前的状态...离子有你试图使用$ state.go()而不是$ location? –
http://stackoverflow.com/questions/14070285/how-to-implement-history-back-in-angular-js? –
@federicoscamuzzi感谢队友,它的工作。我可以将'$ state.go()'嵌套到返回的promise中。正是我在找什么。我不知道它是否是最美丽的解决方案,但它的工作:) – Mazz