Skip to content

$urlRouterProvider.otherwise catches links to the abstract parent #11

Open
@iagoqo

Description

@iagoqo

I have set up a redirect to a 404 info page on the $urlRouterProvider.otherwise that triggers for URLs that don't match any state.

$urlRouterProvider.otherwise(function($injector){
  var $state = $injector.get('$state'),

  $state.go('app.root.notFound');
});

The default property works fine if I click the link directly, but when I ctrl+click the link with the parent state or put the URL directly, it gets caught by the otherwise and redirects to the not-found state.

.state('app.root.details.settings', {
  abstract: true,
  default: '.main',
  url: '/settings',
  views: {
    '[email protected]': {
      templateUrl: 'pages/details/settings/settings-view.html',
      controller: 'SettingsController'
    }
  }
})
.state('app.root.details.settings.main', {
  url: '/main',
  views: {
    '[email protected]': {
      templateUrl: 'pages/details/settings/main/settings-main-view.html',
      controller: 'SettingsMainController'
    }
  }
})

So if I put in the location bar www.mysite.com/app/details/settings it will redirect me to the 404 page, when it should go to www.mysite.com/app/details/settings/main.

Is there a way to avoid this currently or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions