简体   繁体   English

AngularJS:如何从window.history中删除当前视图URL?

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

I have #/load-data view with spinner. 我有微调器的#/load-data视图。 When data load is complete controller redirects to differen view $location.path('/show-info/') . 数据加载完成后,控制器重定向到不同的视图$location.path('/show-info/') How to remove #/load-data from history to avoid window.history.back() to #/load-data view? 如何从历史记录中删除#/ load-data以避免window.history.back()进入#/ load-data视图?

You could use the $location.replace() method to replace the last history entry. 您可以使用$location.replace()方法替换上一个历史记录条目。

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: 因此,当显示微调器时,可以使用以下几行切换到实际视图show-info

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

Or shorter: 或更短:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM