javascript - AngularJS $state does not change view -
in angularjs application in run() function want send user signin page if not logged in. here code:
.run(['$state', function($state) { $state.go('signin') .then(function(promise){}, function(reject) { console.log(reject) } ); }]); in console following:
error: transition superseded {stack: (...), message: "transition superseded"} neither $state.transitionto('signin') doesn't work. have idea why happens, i've never encountered this.
i think should checking authentication in $stateprovider instead of run(). instead:
$stateprovider .state('auth', { abstract: true, resolve: { user: ['auth', '$q', function (auth, $q) { if (auth.isauthenticated()) { //... } else { //... } }] } })
Comments
Post a Comment