import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import {HomeComponent} from './home/home.component'; import {LoginService} from './login.service'; import {SamplesComponent} from './samples/samples.component'; const routes: Routes = [ {path: '', component: HomeComponent}, {path: 'samples', component: SamplesComponent}, {path: 'replace-me', component: HomeComponent, canActivate: [LoginService]}, // if not authenticated { path: '**', redirectTo: '' } ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { }