Angular2 rc3 router alpha 3.0.0.7 default route

angular2 rc3 ... Using the new router (alpha 3.0.0-alpha.7), how do I specify a default route? useAsDefault is an old router ... and "*" doesn't seem to work.

this shoud makes it clear what I want ... I cannot get the "NotFoundComponent" part to work.

export const routes: RouterConfig = [
    { path: 'abc', component: AbcComponent },
    { path: 'def', component: DefComponent },
    { path: '', component: HomeComponent },
    { path: '*', component: NotFoundComponent }  // something like this
];

thank!

+2
source share
1 answer

I believe it should be

{ path: '**', component: NotFoundComponent }

Here is the doc

By the way

There is a way if you want to set root for the default route.

Set pathMatch = 'full' and set the value of redirectTo

[
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'teams'
  },
  {
    path: 'teams',
    component: TeamsComponent
  }
]

Here is a post saying this

+3
source

All Articles