ui-router - reloading current state

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.


Inside javascript You can call current state like so:

$state.go ('.', { search: vm.searchText } )

As of version 1.2.5 you can also use just reload the state:

$state.reload()

That's all nice, but I prefer a way to reload state with different params within a directive. So I looked inside ui-router source code just to understand that uiSref directive is ignored when the state remains the same. While it is nice to prevent reloading if nothing really changed, changing params inside the state could be useful in some cases.

So I created my own directive uiSrefParams: https://gist.github.com/IlanFrumer/8281567

Example

<span>Change language:</span>
<a ui-sref-params="{lang: 'en'}">english</a>
<a ui-sref-params="{lang: 'ru'}">russian</a>

Hope that helps.


try this

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