2

One way to define a default routes with the new RC router is

@Routes([{ path: '/',  component: Home }])

but how can I show initially a page with a non-empty path? like

@Routes([{ path: '/home',  component: Home }])

that will never show the home content, but I want it.

How can this be done in the new RC1 router ?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Pascal
  • 12,265
  • 25
  • 103
  • 195

2 Answers2

3

>= RC.4

{ path: '', redirectTo: '/home', pathMatch: 'full' }
{ path: '/home',  component: Home }

<= RC.2

useAsDefault is not yet supported in the new router. Create a dummy component for the / route that forwards to /home

export class DummyComponent {
  constructor(private router:Router) {
    setTimeout(() => this.router.navigate('/home'));
  }
}

There is also currently no option to skip adding the navigation to the history which might cause issues with the back button.

The router issues are being worked on...

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
1

with rc4 you can use wildcard routes like this { path: '**', redirectTo: 'link/to/default/route' }

Gaurav Mukherjee
  • 6,205
  • 2
  • 23
  • 33