angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

Update docs about hookResult, as it's not working that way #3507

Closed dietergeerts closed 4 years ago

dietergeerts commented 7 years ago

This is a:

My version of UI-Router is: @uirouter/angularjs v1.0.3

Bug Report

Current Behavior:

I have an onEnter in my state, and when I return a state, nothing happens. Though it's described in the docs: HookResult: true | false | void | TargetState | Promise<true | false | void | TargetState>

Expected Behavior:

That it just works like documented. (a lot of the documentation is really out of date.

Though there is a workaround, but I don't know if that's the way it should be done:

$transition$.router.stateService.transitionTo(myStateDefinition);
return false;
kaidjohnson commented 7 years ago

Not sure this is a bug. Try returning a new TargetState:

$transitions.onEnter({}, function (transition) {
  return transition.router.stateService.target(myStateDefinition);
});
dietergeerts commented 7 years ago

In the meantime I already found out that returning a target state works, but it should still be documented.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.