ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

Transition to same state from controller doesn't update location

Open aeternusrahl opened this issue 12 years ago • 1 comments

There seems to be an issue where if you perform a state change while already transitioning to that same state then the views & controllers will update correctly but the location in the URL bar will not update.

So for example, the app is in state one and state one's controller is listening for $destroy events...

app.controller('OneCtrl', function ($scope, $state) {
  $scope.$on('$destroy', function(){
    $state.go('two');
  });
});

If the user clicks a link to transition to state 'two' then the correct view for state 'two' will be displayed but the location in the URL bar will still read state /one.

For a full example, check out http://embed.plnkr.co/vP4R04YV6wg9tXnovDEv. If you download the example and open it in a browser, the url will read '/one' but state two's view will be displayed.

I ran across this when I had a controller automatically transition to another state when a websocket disconnected. But i also had code in the $destroy event to close the websocket when the user transitions away from the state.

I believe this was previously working in version 0.2.0. I noticed it after upgrading to 0.2.10

aeternusrahl avatar May 28 '14 22:05 aeternusrahl

https://gist.github.com/eddiemonge/f6a58169c2846731a1eb

eddiemonge avatar Aug 04 '15 00:08 eddiemonge