Last active
September 14, 2018 19:49
-
-
Save rexar1988/b622fd80b1b0d4a24c0713733e25c041 to your computer and use it in GitHub Desktop.
Angular: Guard
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 { CanActivate } from '@angular/router'; | |
@Injectable() | |
export class AuthGuard implements CanActivate { | |
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean { | |
return true; | |
} | |
} |
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 { AuthGuard } from './guard.service'; | |
const adminRoutes: Routes = [ | |
{ | |
path: 'admin', | |
component: AdminComponent, | |
canActivate: [AuthGuard] | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment