I'm submitting a...
Current behavior
Inside a route guard, injecting ActivatedRoute and attempting relative navigation via this.router.navigate(['../sibling'], {relativeTo: this.route}) results in a Error: Cannot match any routes. URL Segment: 'sibling'
Expected behavior
Relative navigation should work normally
Minimal reproduction of the problem with instructions
A stackblitz example of the issue can be seen here: https://stackblitz.com/edit/angular-gitter-k7fjds
What is the motivation / use case for changing the behavior?
- This appears to be a bug
- If a user navigates to a child route and includes a specific queryParam, I'd like to redirect the user to a sibling route. Currently, this does not appear to be possible inside a route guard with relative navigation.
Additional Information
It appears that the ActivatedRoute injected into a route guard is always an instance of the root route. Inside a route guard, this.router.navigate(['.'], {relativeTo: this.route}) always takes the user back to the root route, rather than navigating them to the same route they are currently on.
Environment
Angular version: 5.0.0
Browser:
- [x] Chrome (desktop) version 64
I'm submitting a...
Current behavior
Inside a route guard, injecting
ActivatedRouteand attempting relative navigation viathis.router.navigate(['../sibling'], {relativeTo: this.route})results in aError: Cannot match any routes. URL Segment: 'sibling'Expected behavior
Relative navigation should work normally
Minimal reproduction of the problem with instructions
A stackblitz example of the issue can be seen here: https://stackblitz.com/edit/angular-gitter-k7fjds
What is the motivation / use case for changing the behavior?
Additional Information
It appears that the
ActivatedRouteinjected into a route guard is always an instance of the root route. Inside a route guard,this.router.navigate(['.'], {relativeTo: this.route})always takes the user back to the root route, rather than navigating them to the same route they are currently on.Environment