5

I have an app setup with 2 states, A and A.B done this way:

$stateProvider.state('A', {
        url: "/A/{aId}",
        controller: 'AController',
        templateUrl: function($stateParams) {
            return "/A/" + $stateParams.aId + "/layout";
        }
    }).state('A.B', {
        url: "/B/{bId}",
        controller: 'BController',
        templateUrl: function($stateParams) {
            return "/A/" + $stateParams.aId + "/B/" + $stateParams.bId+ "/layout";
        }
    });

When I'm in state A.B ( the url would be somthing like #/A/12/B/123 ) and go back using the back button of the browser or transitionTo the url changes, state A.B is cleared but state A doesn't render back. As far as I can tell the controller isn't triggered.

So if I'm in A/12/B/123 and go back to A/12 nothing happens, but if I go back to A/13 ( using transitionTo ) it renders.

On the sample app from angular-ui-router project this scenario works fine, so I think there might be something wrong in my setup. I think it's worth mentioning that on index.html I have a ui-view which loades state A and the template for state A has another ui-view that loads state A.B

If anyone could help, I would really appreciate it

Grig
  • 51
  • 1
  • 4
  • 1
    I believe there is still an open issue on this: https://github.com/angular-ui/ui-router/issues/52 – Brian Lewis Sep 23 '13 at 18:04
  • Yes, I saw that issue but the behaviour I'm describing works well in their sample app. http://angular-ui.github.io/ui-router/sample/ – Grig Sep 23 '13 at 18:09
  • Could you post a Plunkr that demonstrates the issue? This is pretty standard behavior that generally works fine in all cases. – Nate Abele Sep 25 '13 at 13:28
  • 1
    I found the problem...it was that on the layout of state A there was the content of the state and a ui-view for state A.B. When going to A.B the content from A was hidden. When going back te ui-view was cleared but the content remained hidden. Thank you for the help – Grig Sep 26 '13 at 12:52
  • 3
    @Grig It would be helpful to others if you could add an answer yourself. – Gildor Jan 17 '15 at 04:44
  • If someone has a similar problem, should try the answer by Ken Mbuki... Detailed info [link](http://stackoverflow.com/questions/21714655/reloading-current-state-refresh-data) – georgeos Feb 10 '17 at 22:23

1 Answers1

0

Have you tried using this:

$state.reload()

Its a method that force reloads the current state. All resolves are re-resolved, events are not re-fired, and controllers reinstantiated

This is just an alias for:

$state.transitionTo($state.current, $stateParams, { 
      reload: true, inherit: false, notify: false 
    });
Sir Mbuki
  • 1,200
  • 8
  • 7