import { NgModule } from '@angular/core' ; import { Routes , RouterModule } from '@angular/router' ; import { HomeComponent } from './components/home/home.component' ; import { LoginComponent } from './components/login/login.component' ; import { RegisterComponent } from './components/register/register.component' ; import { AuthGuardGuard } from './guards/AuthGuard/auth-guard.guard' ; import { LoginGuard } from './guards/Login/login.guard' ; const routes = [ { path : "" , redirectTo : '/login' , pathMatch : 'full' , canActivate : [ LoginGuard ] } , { path : "login" , component : LoginComponent , canActivate : [ LoginGuard ] } , { path : "home" , component : HomeComponent , canActivate : [ AuthGuardGuard ] } , { path : "register" , component : RegisterComponent , canActivate : [ LoginGuard ] } , { path : "**" , redirectTo : '/login' , pathMatch : 'full' , canActivate : [ LoginGuard ] } ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes ) ] , exports : [ RouterModule ] } ) export class AppRoutingModule { }