import { AuthService } from './../services/auth.service' ; import { Injectable } from '@angular/core' ; import { CanActivate , ActivatedRouteSnapshot , RouterStateSnapshot , Router , Route } from '@angular/router' ; import { Observable } from 'rxjs' ; @ Injectable ( ) export class AuthGuard implements CanActivate { constructor ( private _authService , private _router ) { } canActivate ( next , state ) { if ( this . _authService . isAuthenticated ( ) ) { return true ; } this . _router . navigate ( [ '/login' ] ) ; return false ; } }