角度子子模块路由

时间:2017-11-24 23:01:04

标签: angular angular2-routing

有人可以解释为什么我的路由在这里不起作用吗? AdminComponent和BlogAdminComponent都是shell组件(例如<router-outlet></router-outlet>)。我希望BlogAdminComponent能够加载DashboardComponent,但事实并非如此。我能够通过在家庭管理路线中的博客下列出孩子并完全删除博客路线来实现这一点。 App,home-admin和blog是模块,这就是为什么每个都有自己的routing.module文件。

app / app-routing.module(文件夹)

 const routes: Routes = [
    {path: '', component: ComingSoonComponent},
    {path: 'home-admin', component: AdminComponent},
    {path: '**', redirectTo: ''},
  ];

app / home-admin / home-admin-routing.module(子文件夹)

const routes: Routes = [

 {
   path: 'home-admin', component: AdminComponent,
   children: [

  {
    path: '',
    children: [

      {path: '', redirectTo: 'blog', pathMatch: 'full'},
      {path: 'blog', component: BlogAdminComponent,

      },

      {path: 'demo', component: DemoComponent},
      {path: 'notified', component: NotifiedComponent},
    ]
   }
  ]
 }
];

app / home-admin / blog / blog-routing.module(子子文件夹)

const routes: Routes = [

{
  path: 'home-admin/blog', component: BlogAdminComponent,
  children: [

  {
    path: '',
    children: [

      {path: '', component: DashboardComponent},
      {path: 'create', component: CreateBlogComponent},
    ]
  }
]

} ];

0 个答案:

没有答案