We are using Angular 12 and trying to skip location change inside Router guard.Even if skipLocationChange = true, the location is always getting changed.
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
CanActivate,
RouterStateSnapshot,
Router
} from '@angular/router';
@Injectable()
export class TestGuard implements CanActivate {
constructor( private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
this.router.getCurrentNavigation().extras.queryParamsHandling = "merge";
this.router.getCurrentNavigation().extras.skipLocationChange = true;
return true;
}
}
skipLocationChange is not working. The location is always getting changed.