Child routes let you nest views inside a parent layout, a settings page with tabs, or a dashboard with a persistent sidebar. This lesson covers configuring and rendering nested routes.
What Are Child Routes?
A child route is a route nested inside another route's children array. The parent route typically renders a layout component containing its own <router-outlet>, where the matched child route's component renders.
This pattern is common for dashboards, settings pages, and any UI with a persistent shell (navigation, header) surrounding content that changes based on the URL.
The parent's component acts as a shell: it renders shared UI (like tabs or a sidebar) plus a <router-outlet> for whichever child route is currently active.
The relative links (profile, security, no leading slash) resolve relative to the parent's own path segment.
Relative Navigation From Code
When navigating programmatically between sibling child routes, use relativeTo with the current ActivatedRoute instead of hardcoding the full absolute path, keeping the navigation resilient if the parent path ever changes.
Without a default, visiting just /settings (with no child segment) would render the layout with an empty outlet. An empty-path redirect child route fixes this by sending users to a sensible default tab.
Forgetting to add a <router-outlet> inside the parent layout's own template.
Using absolute paths (with a leading slash) for links meant to be relative to the parent route.
Omitting a default empty-path child redirect, leaving an empty outlet when only the parent path is visited.
Deeply nesting child routes without a clear reason, making the route tree hard to reason about.
Key Takeaways
Child routes nest inside a parent route's children array and render into the parent's own <router-outlet>.
Child route paths are relative to their parent, not absolute.
A default empty-path redirect child avoids an empty outlet at the parent's bare path.
Relative navigation with relativeTo keeps sibling navigation resilient to path changes.
Pro Tip
Keep parent layout components focused purely on shared shell UI and the nested <router-outlet>; avoid duplicating data-fetching logic there that individual child routes could resolve for themselves.
You now understand child routes and nested layouts. Next, learn about Route Guards to control access to specific routes.