使用LoadChildren进行Angular 2路由

Ayz*_*Pat 1 typescript angular-routing angular

我正在使用此代码进行路由

{ 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 }]
   }, 
]},
Run Code Online (Sandbox Code Playgroud)

在这里,当URL是/dashboard我需要它路由到/dashboard/first...

我该如何实现?

Sur*_*yan 6

您已经在Dashboard组件中。仅使用first,不使用dashboard/first。

 { path: '', children: [
    { path: '', component:DashboardComponent ,
        children:[
          { path: '', redirectTo:'first',pathMatch:'full' },
          { path: 'first', component: FirstComponent },
          { path: 'second', component: SecondComponent },
        ]  
     }, 
  ]},
Run Code Online (Sandbox Code Playgroud)