Closed doggy8088 closed 7 years ago
Great idea, thanks!
Do you have an example of what you think they should look like?
You can reference the default template in the Angular CLI ng g guard
command.
Here is a sample that generated from ng g guard login
command. It's a CanActivate
guard.
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class LoginGuard implements CanActivate {
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return true;
}
}
Thanks!!
Published in v4.2.1
There are four different route guard types we can use to protect our routes:
If you providing these route guard templates will be very nice.
Thanks!