I'm using ui-router and registered two $stateChangeStart handlers for login page redirection.
function func1(e,to,toParams, from, fromParams){
....
if (notAuthenticated) {
e.preventDefault();
$state.go('login');
}
}
function func2(e,to,toParams, from, fromParams){
...
console.log('func2', from, to, e.defaultPrevented);
}
$rootScope.on('$stateChangeStart', func1);
$rootScope.on('$stateChangeStart', func2);
As func1 preventDefault(), I can see that in func2 e.defaultPrevented is true. I just don't understand why preventing default in func1 does not stop func2 from executing. Is this behaviour by design? And if it is, what does "default" mean?
Here's the plunk: http://plnkr.co/edit/o81NVo?p=preview You can clear the console and rerun it to see the log.