2017-02-16 122 views
0

我使用此代码为路由 - >角使用2路由LoadChildren

{ 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 }, 
] 

    }, 
    ]}, 

这里当网址/仪表板我需要它路由到/仪表板/第一..

我该如何实现它?

+0

尝试'redirectTo: 'first'',而不是'redirectTo:' 仪表盘/ first'' – AngularChef

+0

它在哪儿你说了redirectTo:第一,而不是redirectTo: '仪表盘/第一'? –

+0

错误...在您提供的代码中。感谢好友 – AngularChef

回答

2

您已在Dashboard组件中。只使用first,而不是dashboard/first

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