File

src/app/shared/guard/auth.guard.ts

Index

Methods

Constructor

constructor(router: Router)
Parameters :
Name Type Optional Description
router Router

Methods

canActivate
canActivate()
Returns : boolean
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { Router } from '@angular/router';

@Injectable()
export class AuthGuard implements CanActivate {

    constructor(private router: Router) { }

    canActivate() {
        if (localStorage.getItem('isLoggedin')) {
            return true;

        }

        this.router.navigate(['/login1']);
        return false;
    }

}

results matching ""

    No results matching ""