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