Olá, estou com esse erro e não consigo encontrar o problema, será que alguém pode me dar uma luz?
Error: Uncaught (in promise): Error: The requested path contains undefined segment at index 1 Error: The requested path contains undefined segment at index 1 at validateCommands (router.js:4101) at Router.push../nodemodules/@angular/router/fesm5/router.js.Router.navigate (router.js:3637) at AuthGuard../src/app/core/auth/auth.guard.ts.AuthGuard.canActivate (auth.guard.ts:19) at MapSubscriber.project (router.js:2799) at MapSubscriber.push../nodemodules/rxjs/esm5/internal/operators/map.js.MapSubscriber.next (map.js:75) at MapSubscriber.push../node_modules/rxjs/esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:93) at Observable.subscribe (subscribeToArray.js:9) at Observable.push../node_modules/rxjs/esm5/internal/Observable.js.Observable.subscribe (Observable.js:161) at MapOperator.push../nodemodules/rxjs/esm5/internal/operators/map.js.MapOperator.call (map.js:51) at Observable.push../nodemodules/rxjs/esm5/internal/Observable.js.Observable.subscribe (Observable.js:158) at resolvePromise (zone.js:831) at resolvePromise (zone.js:788) at zone.js:892 at ZoneDelegate../nodemodules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423) at Object.onInvokeTask (core.js:3811) at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422) at Zone../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195) at drainMicroTaskQueue (zone.js:601)
conferi inúmeras vezes o método canActivate, o meu auth.guard.ts está assim:
import { UserService } from "../user/user.service";
import { Injectable } from "@angular/core";
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from "@angular/router";
import { Observable } from "rxjs";
@Injectable({ providedIn:'root' })
export class AuthGuard implements CanActivate{
constructor (private userService: UserService,
private router: Router) { }
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot):
boolean | Observable<boolean> | Promise<boolean> {
if(this.userService.isLogged()){
this.router.navigate(['user', this.userService.getUserName()])
return false;
}
return true;
}
}