angular-ui / ui-router

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

TypeError: stateName.indexOf is not a function #3743

Closed adamreisnz closed 4 years ago

adamreisnz commented 5 years ago

This issue tracker is for Bug Reports and Feature Requests only.

This is a (check one box):

My version of UI-Router is: 1.0.20 (core 5.0.21)

Bug Report

Current Behavior:

ERROR TypeError: stateName.indexOf is not a function at StateMatcher.isRelative (ui-router-core.js:1751) at StateMatcher.find (ui-router-core.js:1759) at new TargetState (ui-router-core.js:1162) at StateService.target (ui-router-core.js:3980) at auth.js:45 at processQueue (angular.js:9493) at angular.js:9539 at Scope.$digest (angular.js:10096) at Scope.$apply (angular.js:10238) at done (angular.js:6404)

This is triggered from the following (simplified) code:

$transitions.onBefore({}, transition => {
   const target = transition.targetState();
   return transition.router.stateService.target(target);
});

Expected Behavior:

To be redirected to the target state. This used to work fine several versions back. As per the docs: https://ui-router.github.io/ng1/docs/latest/classes/state.stateservice.html#target

This is a factory method for creating a TargetState

This may be returned from a Transition Hook to redirect a transition, for example.

Parameters identifier StateOrName

Link to Plunker or stackblitz that reproduces the issue:

https://stackblitz.com/edit/ui-router-angularjs-pcj7tg

adamreisnz commented 5 years ago

Simply returning target seems to work now.

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.