Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

useAsDefault in parent route doesn't redirect to default child #646

@ericmartinezr

Description

@ericmartinezr

From this question

In this plnkr from the docs the current useAsDefault doesn't work as expected.

  // AppComponent.ts
  { // Crisis Center child route
    path: '/crisis-center/...',
    name: 'CrisisCenter',
    component: CrisisCenterComponent,
    useAsDefault: true // <<--
  },

  // CrisisCenterComponent
  @RouteConfig([
  {path:'/',         name: 'CrisisCenter', component: CrisisListComponent, useAsDefault: true},
  {path:'/:id',      name: 'CrisisDetail', component: CrisisDetailComponent},
  {path:'/list/:id', name: 'CrisisList',   component: CrisisListComponent}
])

Note the extra useAsDefault in the AppComponent's RouteConfig. This doesn't work as noted in the question. By removing it and adding a redirectTo it works as expected.

  // AppComponent.ts
  { path : '/', redirectTo : ['CrisisCenter'] },
  { // Crisis Center child route
    path: '/crisis-center/...',
    name: 'CrisisCenter',
    component: CrisisCenterComponent
  },

I'm not aware to be honest of that behavior in Router (although it makes perfect sense, asking it as a feature would be nice), but I think it's a mistake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions