import { NgModule } from '@angular/core' ; import { RouterModule , Routes } from '@angular/router' ; import { AuthGuard } from './auth' ; export const routes = [ { path : 'home' , loadChildren : ( ) => import ( './home/home.module.ngfactory' ) . then ( ( m ) => m . HomeModuleNgFactory ) , canActivate : [ AuthGuard ] , } , { path : 'login' , loadChildren : ( ) => import ( './login/login.module.ngfactory' ) . then ( ( m ) => m . LoginModuleNgFactory ) , } , { path : 'register' , loadChildren : ( ) => import ( './register/register.module.ngfactory' ) . then ( ( m ) => m . RegisterModuleNgFactory ) , } , { path : '**' , redirectTo : '/login' } , ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes , { } ) ] , exports : [ RouterModule ] , } ) export class AppRoutingModule { }