Getting a "Transition Rejection( .." error after using "$state.go('stateName', null, {'reload':true});"
Solution 1
You can use:
$state.reload();
or
$state.transitionTo($state.current, $stateParams, {
reload: true,
inherit: false,
notify: true
});
Solution 2
The error is occurring because you're creating a new transition within an existing one. As the error says, the transition to home
is being superseded by the transition to movies
which you're creating with $state.go('movies'[, ...]);
.
To stop the error occurring place $state.go('movies')
within a $timeout
. E.g.
$timeout(function() {
$state.go('movies', null, {'reload':true});
});
Related videos on Youtube
NoviceCoder
Hi, I am Pratik Basak. An experienced UI/Front End Developer individual working in the web industry for the past 6 years. I am always into learning stuff whenever time permits. I love to stay updated with the latest stuff in my domain and most importantly apply it in a necessary project to give it a cutting edge advantage over my previous works. I kind of compete with myself to stay ahead.
Updated on July 09, 2022Comments
-
NoviceCoder almost 2 years
I was trying to reload my controller using
$state.go('movies', null, {'reload':true});
But after using this, I am getting this error
Transition Rejection($id: 1 type: 2, message: The transition has been superseded by a different transition, detail: Transition#63( 'home'{} -> 'movies'{} ))
I am clueless why is this happening. Although the functionality is working fine.
Code:
$scope.filterMovies = function(genre){ var filteredMovies = []; MoviesService.msGetData().then(function(dataparam){ $scope.movielist = dataparam; for(var idx=0; idx<$scope.movielist.length; idx++){ if($scope.movielist[idx].genres.indexOf(genre) > -1){ filteredMovies.push($scope.movielist[idx]); MoviesService.msSetFilteredMovies(filteredMovies); //$state.go('movies'); $state.go('movies', null, {'reload':true}); } } }); }
Note: I am using AngularJS v1.6.5 and angular-ui-router v1.0.5
-
NoviceCoder almost 7 yearsearlier I have tried your code and it was not working