import { Injectable } from '@angular/core' ; import { CanActivate , ActivatedRouteSnapshot , RouterStateSnapshot , UrlTree , Router } from '@angular/router' ; import { Observable } from 'rxjs' ; import { AuthService } from './service/auth.service' ; @ Injectable ( { providedIn : 'root' } ) export class AuthGuard implements CanActivate { constructor ( private auth , private route ) { } canActivate ( next , state ) { if ( this . auth . isLoggedIn ) { return true ; } this . route . navigate ( [ '/sigin' ] ) ; } }