i have an issue on CanActivate
import { AuthService } from './auth.service';
import { CanActivate } from '@angular/router/src/utils/preactivation';
import { ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService,
private router: Router)
{
}
canActivate(route: ActivatedRouteSnapshot,state: RouterStateSnapshot )
: Observable<boolean> | Promise<boolean> |boolean {
if (this.authService.isAuth) {
return true;
}else{
this.router.navigate(['/auth']);
}
}
}
and it's telling me this :
ERROR in src/app/services/auth-guard.service.ts(10,14): error TS2720: Class 'AuthGuard' incorrectly implements class 'CanActivate'. Did you mean to extend 'Can Activate' and inherit its members as a subclass?
Type 'AuthGuard' is missing the following properties from type 'CanActivate': path, route
But I don't understand why ?
Great thanks to everyone !