I went through a few questions, but did not find a solution.
I have a problem with handling states.
$urlRouterProvider.otherwise( function($injector, $location) {
var $state = $injector.get("$state");
$state.go("cover");
});
$stateProvider
.state('auth', {
url: '/auth',
templateUrl: '../views/authView.html',
controller: 'AuthController as auth'
})
.state('users', {
url: '/users',
templateUrl: '../views/userView.html',
controller: 'UserController as user'
})
....
how routing works in my application.
app.run(function($rootScope, $state, $location) {
$rootScope.$on('$stateChangeStart', function(event, toState, fromState) {
if($rootScope.authenticated && $rootScope.onboard == 0) {
$state.transitionTo("onboard", null, {notify:false});
$state.go('onboard');
}
...
Each time I change my route, this block is triggered a hundred times, but I want it to simply check whether the user has been checked and if any of his forms have been completed or not, and if he simply is not redirected to the forms themselves.
I tried different ways with preventDefault(); or without, the same thing.
source
share