這裏是我的路由模塊。Angular2組織路由模塊
@NgModule({
imports: [
RouterModule.forChild([
{
path: "",
component: AdminComponent,
children: [
{
path: "users",
component: ParentComponent
children: [
{
path: ":id",
component: AnotherComponent
}
]
}
]
}]
)
],
exports: [
RouterModule
]
})
export class AdminRoutingModule {}
通過這樣做,我需要在我ParentComponent
一個<router-outlet></router-outlet>
來指定。這裏唯一的問題是AnotherComponent
不是ParentComponent
的一部分,這是兩個不同的頁面。所以也許一個更好的結構會讓他們處於同一水平。我之所以選擇這種結構是因爲AnotherComponent
只能從ParentComponent
到達。這裏最明智的做法是什麼?
不應該是一個問題嗎?組件的代碼是什麼? –