I'm using angular-ui's router (v0.2.0) in a project and we're trying to reload a view. I've tried $state.transitionTo and also $state.go, but neither seem to do anything. Would anyone know how to do a reload?
Thank you!
If you are going from state A to state A again, the internals of the angular-ui would forbid it from reloading the state. You'd have to go to a different state to have a reload. That is to avoid clicking many times on the same link issuing a reload.
You can try switching to the same state, but with slightly different params, if you are that desperate to reissue a reload. But in my point of view, if you are in the same state, a reload shouldn't happen.
There is already also a similar question on SO: $route.reload() does not work with ui-router
Comment on similar question Reloading current state - refresh data by SimplGy:
Probably worth noting that none of these [edit: meaning $state.transitionTo('state'), $state.reload() or $state.go($state.current, {}, {reload: true})] actually reload the page as well. If you want to reload the state AND the page, there is no ui-router method for it I think. Do window.location.reload(true)
Another comment by edhedges improved this one by mentioning the use of
$window.location.reload()
Which works and I recommend using for the reloading a ui-view.