Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to preventDefault action with onEnter hook and $transition$? (new ui-router)

I'm using ui-router 1.0.0-alpha.5. Old events are deprecated there.

so I'm trying to convert

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

into:

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

how could I prevent default action from here?

like image 536
Stepan Suvorov Avatar asked Jun 30 '16 08:06

Stepan Suvorov


1 Answers

Looks like I found the answer:

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

i.e. you need to return rejected promise.

like image 109
Stepan Suvorov Avatar answered Nov 12 '22 11:11

Stepan Suvorov