import { NgModule } from '@angular/core' ; import { Routes , RouterModule , PreloadAllModules } from '@angular/router' ; import { HomeComponent } from './home.component' ; import { PageNotFoundComponent } from './page-not-found.component' ; const routes = [ { path : '' , pathMatch : 'full' , redirectTo : 'home' } , { path : 'home' , component : HomeComponent } , { path : 'heroes' , loadChildren : 'app/heroes/heroes.module#HeroesModule' } , { path : 'villains' , loadChildren : 'app/villains/villains.module#VillainsModule' } , { path : '**' , pathMatch : 'full' , component : PageNotFoundComponent } ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes , { preloadingStrategy : PreloadAllModules } ) ] , exports : [ RouterModule ] } ) export class AppRoutingModule { }