Video Course

Routing Angular v2+ Applications: Lesson 14 of 23

Child Routes

Up Next

Lazy Loading

Autoplaying in 7 seconds!


Create a Free Account to Watch

Sign Up Now

Login to your account

The Angular 2 router allows us to create child routes that will be nested underneath a certain route.

In our case, we'll be nesting the :username route in our about.routing.ts.

import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AboutComponent } from './about.component';
import { AboutUserComponent } from './about-user.component';
import { AboutSectionComponent } from './about-section.component';

const aboutRoutes: Routes = [
    path: 'about',
    component: AboutSectionComponent,
    children: [
        path: '',
        component: AboutComponent
        path: ':username',
        component: AboutUserComponent

export const aboutRouting: ModuleWithProviders = RouterModule.forChild(aboutRoutes);

Chris Sevilleja

157 posts

Co-founder of Slapping the keyboard until something good happens.