CoreUI ONE — 250+ PRO components and 25+ admin templates for React, Angular, Vue, Bootstrap and Next.js, plus Data Grid, Scheduler, 4,300+ PRO icons and the Next.js boilerplate. One license. → See what you get

How to create child routes in Angular

Child routes in Angular enable hierarchical navigation structures, allowing you to create nested components that correspond to URL segments for complex applications. As the creator of CoreUI, I’ve implemented nested routing systems for large-scale Angular projects. The most effective approach is defining child routes within parent route configurations using the children property. This provides organized, maintainable navigation structures that scale well with application complexity.

Define child routes using the children property in your route configuration to create nested navigation structures.

// app-routing.module.ts
import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { DashboardComponent } from './dashboard/dashboard.component'
import { UserListComponent } from './users/user-list.component'
import { UserDetailComponent } from './users/user-detail.component'
import { UserProfileComponent } from './users/user-profile.component'

const routes: Routes = [
  {
    path: 'dashboard',
    component: DashboardComponent,
    children: [
      { path: '', redirectTo: 'overview', pathMatch: 'full' },
      { path: 'overview', component: OverviewComponent },
      { path: 'analytics', component: AnalyticsComponent }
    ]
  },
  {
    path: 'users',
    component: UserListComponent,
    children: [
      { path: ':id', component: UserDetailComponent },
      { path: ':id/profile', component: UserProfileComponent }
    ]
  }
]

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

// dashboard.component.html
<div class="dashboard">
  <nav>
    <a routerLink="overview">Overview</a>
    <a routerLink="analytics">Analytics</a>
  </nav>
  <router-outlet></router-outlet>
</div>

This configuration creates nested routes where /dashboard/overview loads the DashboardComponent with OverviewComponent as a child, and /users/123/profile loads UserListComponent with UserProfileComponent as a child. The parent component must include <router-outlet></router-outlet> to display child components. Child routes inherit the parent path and can include parameters and redirects.

Best Practice Note:

This nested routing pattern is used extensively in CoreUI’s Angular admin templates for organizing complex dashboard layouts. Always include default redirects for parent routes and use relative navigation in child components for maintainable route structures.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
JavaScript printf equivalent
JavaScript printf equivalent

How to Open All Links in New Tab Using JavaScript
How to Open All Links in New Tab Using JavaScript

How to Remove Underline from Link in CSS
How to Remove Underline from Link in CSS

Understanding and Resolving the “React Must Be in Scope When Using JSX
Understanding and Resolving the “React Must Be in Scope When Using JSX