Skip to content

Instantly share code, notes, and snippets.

@rexar1988
Last active September 14, 2018 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexar1988/b622fd80b1b0d4a24c0713733e25c041 to your computer and use it in GitHub Desktop.
Save rexar1988/b622fd80b1b0d4a24c0713733e25c041 to your computer and use it in GitHub Desktop.
Angular: Guard
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;
}
}
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