Ayz Pat
Ayz Pat

Reputation: 135

Angular 2 routing using LoadChildren

I am using this code for routing

{ path: 'dashboard', loadChildren: './dashboard#DashboardModule'},
{ path: '', children: [     
   { path: '', component:DashboardComponent, children: [
      { path: '', redirectTo:'dashboard/first',pathMatch:'full' },
      { path: 'first', component: FirstComponent },
      { path: 'second', component: SecondComponent }]
   }, 
]},

Here when the url is /dashboard I need it to route to /dashboard/first...

How can I achieve it?

Upvotes: 1

Views: 1659

Answers (1)

Suren Srapyan
Suren Srapyan

Reputation: 68685

You are already in Dashboard component. Use only first, not dashboard/first.

 { path: '', children: [
    { path: '', component:DashboardComponent ,
        children:[
          { path: '', redirectTo:'first',pathMatch:'full' },
          { path: 'first', component: FirstComponent },
          { path: 'second', component: SecondComponent },
        ]  
     }, 
  ]},

Upvotes: 5

Related Questions