UI-Router Reload State without a full page refresh

2019-05-20 09:10发布

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?

2条回答
【Aperson】
2楼-- · 2019-05-20 09:32

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.

查看更多
孤傲高冷的网名
3楼-- · 2019-05-20 09:38

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.

查看更多
登录 后发表回答