Created
August 26, 2017 08:56
-
-
Save seven-cd/5005f3dad6d1908136d82660fa7df798 to your computer and use it in GitHub Desktop.
ng2router-can-load-guard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { CanLoad } from '@angular/router'; | |
import { AuthService } from './auth.service'; | |
@Injectable() | |
export class AuthGuard implements CanLoad { | |
constructor( | |
private authService : AuthService | |
){} | |
canLoad() { | |
if(this.authService.loggedIn) { | |
return this.authService.loggedIn; | |
} else { | |
alert('You are unathorized. Please login'); | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment