使用LoadChildren进行Angular 2路由

艾兹·帕特(Ayz Pat)

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

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

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

我该如何实现?

苏伦·斯拉皮扬(Suren Srapyan)

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章