import { NgModule } from '@angular/core' ; import { RouterModule , Routes } from '@angular/router' ; import { AuthGuard } from './model/auth.guard' ; import { BackendLayoutComponent } from './layout/backend-layout.component' ; import { SimpleLayoutComponent } from './layout/simple-layout.component' ; import { P404Component } from './page/404.component' ; export const routes = [ { path : '' , redirectTo : 'dashboard' , pathMatch : 'full' } , { path : '' , component : BackendLayoutComponent , canActivate : [ AuthGuard ] , children : [ { path : 'dashboard' , loadChildren : ( ) => import ( './dashboard/dashboard.module' ) . then ( m => m . DashboardModule ) } , { path : 'staff' , loadChildren : ( ) => import ( './staff/staff.module' ) . then ( m => m . StaffModule ) } , { path : 'user' , loadChildren : ( ) => import ( './user/user.module' ) . then ( m => m . UserModule ) } , { path : 'setting' , loadChildren : ( ) => import ( './setting/setting.module' ) . then ( m => m . SettingModule ) } ] } , { path : '' , component : SimpleLayoutComponent , children : [ { path : 'login' , loadChildren : ( ) => import ( './login/login.module' ) . then ( m => m . LoginModule ) } , { path : 'logout' , loadChildren : ( ) => import ( './logout/logout.module' ) . then ( m => m . LogoutModule ) } ] } , { path : '**' , component : P404Component } ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes ) ] , exports : [ RouterModule ] } ) export class AppRoutingModule { }