In my state change callback function, I am handling redirection to the same state.
$rootScope.$on('$stateChangeStart', function(event, toState, toStateParams) {
if (toState.name != 'wsConnect') {
console.log("change path!!");
$location.path('/connect');
}
});
Initially, when a user opens a new tab and enters a route with any URL anchor, everything works as expected. The user sees the view based on the callback. However, if the user manually changes the anchor and hits enter, the callback only partially functions - the anchor value is retrieved but the user still sees the view for their original route instead of the anchor.
Refreshing the page seems to resolve this issue temporarily.
To address this problem, I came up with a workaround:
if (toState.name != 'wsConnect') {
console.log("change path!!");
$interval(function () {
$state.go('wsConnect');
$location.path('/connect');
}, 1, 1);
}