没有整页刷新的 UI-Router 重新加载状态 [英] UI-Router Reload State without a full page refresh
问题描述
目前如果我想重新加载一个状态,我必须使用 $state.reload().这会导致整页刷新,非常不友好.我正在寻找一种方法来重新解析我的依赖项并重置控制器.这可能吗?
Currently if I want to reload a state, I have to use the $state.reload(). This causes a full page refresh, which is very unfriendly. I am looking for a way to just re-resolve my dependencies and reset the controller. Is this possible?
推荐答案
补充@Dag 的回答:
Just to add on @Dag 's answer:
请注意,从 0.2.14 开始,您还有一个选项只是重新加载当前状态而不是它的父状态.
Do note, as of 0.2.14 you also have an option to just reload the current state and not it's parent.
所以 $state.go(people.search, {}, {reload: true});
将重新加载 people
状态及其所有子状态.
So $state.go(people.search, {}, {reload: true});
would reload the people
state as well as all its childs.
虽然 $state.go(people.search, {}, {reload: "people.search"});
不会重新加载 people
状态但会重新加载people.search
及其子项.
While $state.go(people.search, {}, {reload: "people.search"});
would not reload the people
state but would reload people.search
and its childs.
这篇关于没有整页刷新的 UI-Router 重新加载状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!