import { NgModule } from '@angular/core' ; import { Routes , RouterModule } from '@angular/router' ; import { PublicGuard , ProtectedGuard } from 'ngx-auth' ; const routes = [ { path : 'login' , canActivate : [ PublicGuard ] , loadChildren : ( ) => import ( './login/login.module' ) . then ( m => m . LoginModule ) } , { path : 'dashboard' , canActivate : [ ProtectedGuard ] , loadChildren : ( ) => import ( './dashboard/dashboard.module' ) . then ( m => m . DashboardModule ) } , { path : '' , redirectTo : 'dashboard' , pathMatch : 'full' } , { path : '**' , redirectTo : 'dashboard' , pathMatch : 'full' } ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes ) ] , exports : [ RouterModule ] } ) export class AppRoutingModule { }