How to reload the current state?
angular-ui, angular-ui-router, angularjs
Solution
This solution works in AngularJS V.1.2.2:
$state.transitionTo($state.current, $stateParams, {
reload: true,
inherit: false,
notify: true
});
Problem
I'm using Angular UI Router and would like to reload the current state and refresh all data / re-run the controllers for the current state and it's parent. I have 3 state levels: directory.organisations.details directory.organisations contains a table with a list of organisations. Clicking on an item in the table loads directory.organisations.details with $StateParams passing the ID of the item. So in the details state I load the details for this item, edit them and then save data. All fine so far. Now I need to reload this state and refresh all the data. I have tried: ``` $state.transitionTo('directory.organisations'); ``` Which goes to the parent state but doesn't reload the controller, I guess because the path hasn't changed. Ideally I just want to stay in the directory.organisations.details state and refresh all data in the parent too. I have also tried: ``` $state.reload() ``` I have seen this on the API WIKI for $state.reload "(bug with controllers reinstantiating right now, fixing soon)." Any help would be appreciated?