AngularJS: How to remove current view url from window.history?

巧了我就是萌 提交于 2019-12-19 05:46:08

问题


I have #/load-data view with spinner. When data load is complete controller redirects to differen view $location.path('/show-info/'). How to remove #/load-data from history to avoid window.history.back() to #/load-data view?


回答1:


You could use the $location.replace() method to replace the last history entry.

Here is the link to the documentation.

So when you are showing the spinner, you could switch to the actual view show-info with the following lines:

$location.path('/show-info/');
$location.replace();

Or shorter:

$location.path('/show-info/').replace();


来源:https://stackoverflow.com/questions/28743405/angularjs-how-to-remove-current-view-url-from-window-history

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!