import { NgModule } from '@angular/core' ; import { RouterModule , Routes } from '@angular/router' ; import { LoginComponent } from './login/login.component' ; import { AboutusComponent } from './aboutus/aboutus.component' ; import { SignupComponent } from './signup/signup.component' ; import { SettingsComponent } from './settings/settings.component' ; import { ReportsComponent } from './reports/reports.component' ; import { DashboardComponent } from './dashboard/dashboard.component' ; import { AuthGuard } from './services/auth-guard.service' ; const routes = [ { path : '' , redirectTo : '/login' , pathMatch : 'full' } , { path : 'login' , component : LoginComponent } , { path : 'dashboard' , component : DashboardComponent , canActivate : [ AuthGuard ] } , { path : 'aboutus' , component : AboutusComponent , canActivate : [ AuthGuard ] } , { path : 'signup' , component : SignupComponent } , { path : 'settings' , component : SettingsComponent , canActivate : [ AuthGuard ] } , { path : 'reports' , component : ReportsComponent , canActivate : [ AuthGuard ] } , { path : '**' , redirectTo : '/login' , pathMatch : 'full' } ] ; @ NgModule ( { imports : [ RouterModule . forRoot ( routes ) ] , exports : [ RouterModule ] } ) export class AppRoutingModule { }