how to set redirects for guards code example
Example: angular guard redirect
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) {}
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (!this.authService.isLoggedIn) {
return this.router.parseUrl('/notauthorized');
} else {
return true;
}
}
}