본문 바로가기

IT

[angular] router nested

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.


^^/

'IT' 카테고리의 다른 글

[angular] redirecting and wildcard  (0) 2018.03.23
[angular] Handling queryParams  (0) 2018.03.23
[angular] retrieve the data as number  (0) 2018.03.21
[angular] QueryParameters and Fragments  (0) 2018.03.21
[angular] route and parameter  (0) 2018.03.19