Search code examples
javascriptangularjsangular-routing

Reload page fails after changing state with $state.transitionTo


In my angular controller, I have part of the code

$state.transitionTo('newState', {}, { notify: false })
  .then(function () {
    $window.location.reload();
  });

Reason for this is that I need to reload the page due some server-side rendering and then go to newState This works fine in Chrome and IE, but in FireFox it reloads the page but stays in the same state. Is this some known issue with FireFox, or am I doing something wrong?


Solution

  • ui-router supports this functionality already:

    $state.go('newState', {}, { notify: false, reload: true });
    

    It's better to use $state.go rather than $state.transitionTo in virtually all cases, fyi.