How to prevent default action using onEnter interception and $ transition $? (new ui router)

I am using ui-router 1.0.0-alpha.5 . Old events are outdated there .

so i try to convert

$rootScope.$on('$stateChangeStart', ($event) => { //some logic $event.preventDefault(); }); 

in:

 $transitions.onEnter({}, ($transition$) => { //... }); 

how can i prevent the default action from here?

+8
javascript angularjs angular-ui-router
source share
1 answer

Looks like I found the answer:

 $transitions.onEnter({}, ($transition$) => { return $q.reject() }); 

i.e. You need to return the rejected promise .

+5
source share

All Articles