import { NgModule } from '@angular/core' ; import { CommonModule } from '@angular/common' ; import { Routes , RouterModule } from '@angular/router' ; import { LoginComponent } from '../app/login/login.component' ; import { HomeComponent } from '../app/home/home.component' ; import { AuthGuardService } from './auth-guard.service' ; const routes = [ { path : '' , redirectTo : 'login' , pathMatch : 'full' } , { path : 'login' , component : LoginComponent } , { path : 'home' , component : HomeComponent , canActivate : [ AuthGuardService ] } ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes ) , CommonModule ] , exports : [ RouterModule ] } ) export class AppRoutingModule { }