AngularJS ui-router:强制重新加载 [英] AngularJS ui-router: force reload
问题描述
我有一个从 index.html 开始并使用 ui-router 的 AngularJS 应用程序.基于触发器,我想重新加载完整页面.我试过了:
I have an AngularJS app starting at index.html and using ui-router. Based on a trigger I want to reload the complete page. I tried:
$state.go($state.current, $stateParams, {
reload: true,
inherit: false,
notify: true
});
但这行不通.它不会重新加载我的初始 index.html.
But that does not work. It doesn't reload my initial index.html.
我能做到:
window.location.href = "index.html";
然后我在我的初始页面上,而不是当前状态.
But then I'm on my initial page, not the current state.
是否应该使用指定当前位置的查询字符串参数将 window.location.href
设置为 index.html
?如果我这样做了,我该如何导航到这个位置?
Should a set window.location.href
to index.html
with query string parameters specifying current location? If I do that, how can I navigate to this location?
推荐答案
目前的技巧是:
$state.go($state.current.name, $state.params, { reload: true });
$state.go($state.current.name, $state.params, { reload: true });
这篇关于AngularJS ui-router:强制重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!