Browserback Problems Using angularui-router

Asked 2 years ago, Updated 2 years ago, 71 views

$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){

  // stop the transition
  event.preventDefault();

 // $resource processing
 , success(function{
    $state.go('state');
 })
 , error (function() {something})

}

Routing uses ui-router.
We have done the above to achieve page transition, but
When you press Back Browser
Loop between the previous screen and the displayed screen. That's it.

If you want to synchronize, or if you want your browser to return or detect progress,
I think we can handle it, but how should we implement it?

angularjs ui-router

2022-09-30 16:47

1 Answers

In this state, it is added to the history of the direction in which it goes after returning to disable it, so the same thing will be repeated again and it will cause a loop.

$state.go('state', {}, {location:'replace'});

If the optional location property of $state.go is "replace", the history will be replaced.


2022-09-30 16:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.