AngularJS:如何从 window.history 中删除当前视图 url? [英] AngularJS: How to remove current view url from window.history?

查看:50
本文介绍了AngularJS:如何从 window.history 中删除当前视图 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有微调器的 #/load-data 视图.当数据加载完成时,控制器重定向到不同的视图 $location.path('/show-info/').如何从历史记录中删除 #/load-data 以避免 window.history.back() 到 #/load-data 视图?

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?

推荐答案

您可以使用 $location.replace() 方法来替换最后一个历史记录条目.

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

这里是文档的链接.

因此,当您显示微调器时,您可以使用以下几行切换到实际视图 show-info:

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();

或更短:

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

这篇关于AngularJS:如何从 window.history 中删除当前视图 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆