IT
[angular] router nested
로바아토
2018. 3. 22. 09:08
we can make nested router.
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'users', component: UsersComponent, children: [
{ path: ':id/:name', component: UserComponent }
]},
{ path: 'servers', component: ServersComponent, children: [
{ path: ':id', component: ServerComponent },
{ path: ':id/edit', component: EditServerComponent }
]}
];
looks pretty good! but it is not enough.
because we need router-outlet for these nested route.
Add <router-outlet></router-outlet> in ServersComponent.html and UsersComponent.html
they have their own children, so need their own router-outlet for their children.
^^/