I have an application that I am building that implements CanActivate on the dashboard route. It works fine accept on page reload, I check a flag in the user service to see i
in AuthGuard
Do this
@Injectable()
export class AuthGuard implements CanActivate {
auth: any = {};
constructor(private authService: AuthService, private router: Router) {
}
canActivate() {
if (/*user is logged in*/) {
this.router.navigate(['/dashboard']);
return true;
}
else {
this.router.navigate(['/Login']);
}
return false;
}
}