UI-路由器重新加载状态,无需刷新整页 [英] 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-路由器重新加载状态,无需刷新整页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!