【发布时间】:2016-11-03 08:44:09
【问题描述】:
路由条件:
1) path: /login , component: LoginComponent
2) path: /inbox , component: InboxMessageComponent
3) path:/inbox/all , "Load InboxMessageListComponent in Right side Box Only",
4) path:/inbox/13 , "Load InboxMessageDetailComponent in Right side Box Only"
所以我创建了两个路由模块 app-routing.module.ts 和 inbox-routing.module.ts。
app-routing.module.ts
@NgModule({
imports: [
RouterModule.forRoot([
{ path: 'login', component: LoginComponent},
{ path: 'inbox', component: InboxMessageComponent },
{ path: '', component: InboxMessageComponent },
{ path: '**', component: NotFoundComponent }
])
],
exports: [RouterModule]
})
inbox-routing.module.ts
@NgModule({
imports: [
RouterModule.forChild([
{path: '/inbox/list',component: InboxMessageListComponent},
{path: '/inbox/detail/:id',component: InboxMessageDetailComponent}
])
],
exports: [RouterModule]
})
app.component.ts
template : '<router-outlet></router-outlet>'<!--This route-outlet will load "LoginComponent/InboxComponent" depending upon the routing. -->
inbox-message.component.ts
template:`
<sidebar-component></sidebar-component>
<router-outlet></router-outlet> <!-- This will load InboxMessageListComponent or InboxMessageDetailComponent -->
`
但问题是一次只有一个在工作。第二个是跳过。
这样的项目如何路由?
【问题讨论】:
-
我也有同样的问题,请问有进展吗?
-
本教程指出了我猜你的问题。 angular-2-training-book.rangle.io/handout/routing/…
标签: angular angular2-routing angular2-template