Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect loop on state with error resolve, using "when" at the root #2692

Closed
rmorrise opened this issue Apr 13, 2016 · 3 comments
Closed

Redirect loop on state with error resolve, using "when" at the root #2692

rmorrise opened this issue Apr 13, 2016 · 3 comments
Labels

Comments

@rmorrise
Copy link

Note: This issue is similar to #1022 (comment), except that in this case, the otherwise function is never invoked.

I have set the following:

$urlRouterProvider.when('/', '/projectView');
$urlRouterProvider.otherwise('/404');

$stateProvider.state('defaultProjectView', 
                {
                    url:'/projectView',
                    template: '<ui-view></ui-view>',
                    controller: ...,
                    resolve: {
                        rootNode: function() { /* returns some promise of data to be loaded */ }
                    }
                }
            });

If rootNode's promise is rejected, the browser goes into an infinite loop, triggering the rootNode function over and over again.

The otherwise function is never invoked.

I am using v0.2.18 in Angular 1.5.2.

As with the other issue, there is a workaround. The when mapping must be changed to:

$urlRouterProvider.when('/', function($injector) {
      var $state = $injector.get('$state');
      return $state.go('defaultProjectView');
    });
@eddiemonge
Copy link
Contributor

Do you have a 404 state?

@rmorrise
Copy link
Author

rmorrise commented Apr 26, 2016

Yes, but it's never invoked in this use case. Here is the 404 state's config:

$stateProvider.state('404', 
    {
          url: '/404',
          templateUrl: 'app/core/404.html',
          title: '404'
    }
);

I also changed the 404 'otherwise' to:

    $urlRouterProvider.otherwise(function($injector) {
      var $state = $injector.get('$state');
      return $state.go('404');
    });

but the 'otherwise' function is not called.

@stale
Copy link

stale bot commented Jan 24, 2020

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.

@stale stale bot added the stale label Jan 24, 2020
@stale stale bot closed this as completed Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants