2017-02-16 124 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 }, 
     ] 
    }, 
    ]},