Answer the question
In order to leave comments, you need to log in
Navigate feature not available in Route?
Angular 2*
import {Injectable} from '@angular/core';
import {Route, CanActivate} from '@angular/router';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private router: Route) {
}
canActivate() {
if (localStorage.getItem('currentUser')) {
return true;
}
this.router.navigate(["/login"]);
return false;
}
}
ERROR in [at-loader] resources/assets/src/app/_guards/auth.guard.ts:13:21
Property 'navigate' does not exist on type 'Route'.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question