UI-Router Reload State without a full page refresh

牧云@^-^@ 提交于 2019-12-07 21:10:28

问题


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?


回答1:


Just to add on @Dag 's answer:

Do note, as of 0.2.14 you also have an option to just reload the current state and not it's parent.

So $state.go(people.search, {}, {reload: true}); would reload the people state as well as all its childs.

While $state.go(people.search, {}, {reload: "people.search"}); would not reload the people state but would reload people.search and its childs.




回答2:


you can try with:

$state.go($state.current.name, $state.params, { reload: true });

it will force transition even if the state or params have not changed without full page refresh. you can pass the state + the params + reload options.

for details look here at "go" method.



来源:https://stackoverflow.com/questions/32097221/ui-router-reload-state-without-a-full-page-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!