import { NgModule } from '@angular/core' ; import { RouterModule , Routes } from '@angular/router' ; import { HomeComponent } from './home.component' ; const routes = [ { path : '' , component : HomeComponent , pathMatch : 'full' } , { path : 'about' , loadChildren : ( ) => import ( './about/about.module' ) . then ( ( m ) => m . AboutModule ) , } , { path : 'user/:id' , loadChildren : ( ) => import ( './user/user.module' ) . then ( ( m ) => m . UserModule ) , } , ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes , { initialNavigation : 'enabled' , } ) , ] , exports : [ RouterModule ] , } ) export class AppRoutingModule { }