Skip to content

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

Closed
@rmorrise

Description

@rmorrise

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');
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions