2017-02-16 6 views
0

Ich verwende diesen Code für das Routing ->Angular 2-Routing LoadChildren

{ path: 'dashboard', loadChildren: './dashboard#DashboardModule'}, 

In meinem Armaturenbrett-Modul verwende ich diese ->

{ path: '', children: [ 


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

    }, 
    ]}, 

Hier, wenn die URL/Armaturenbrett Ich brauche es zu/Dashboard/erste ..

Wie kann ich es erreichen?

+0

Versuchen 'RedirectTo: 'first'' statt' RedirectTo:' Armaturenbrett/first'' – AngularChef

+0

wo es u RedirectTo sagen: zuerst statt RedirectTo: 'Armaturenbrett/first'? –

+0

Errr ... in dem Code, den Sie angegeben haben. – AngularChef

Antwort

2

Sie sind bereits in Dashboard Komponente. Verwenden Sie nur first, nicht dashboard/first.

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