Title: bug: relative navigation doesn't work inside route guards · Issue #22763 · angular/angular · GitHub
Open Graph Title: bug: relative navigation doesn't work inside route guards · Issue #22763 · angular/angular
X Title: bug: relative navigation doesn't work inside route guards · Issue #22763 · angular/angular
Description: I'm submitting a... [x] Bug report 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...
Open Graph Description: I'm submitting a... [x] Bug report Current behavior Inside a route guard, injecting ActivatedRoute and attempting relative navigation via this.router.navigate(['../sibling'], {relativeTo: this.rout...
X Description: I'm submitting a... [x] Bug report Current behavior Inside a route guard, injecting ActivatedRoute and attempting relative navigation via this.router.navigate(['../sibling'], {relativeT...
Opengraph URL: https://github.com/angular/angular/issues/22763
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: relative navigation doesn't work inside route guards","articleBody":"\u003c!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\r\n-->\r\n\r\n## I'm submitting a...\r\n\u003c!-- Check one of the following options with \"x\" -->\r\n\u003cpre>\u003ccode>\r\n[x] Bug report \u003c!-- Please search GitHub for a similar issue or PR before submitting -->\r\n\u003c/code>\u003c/pre>\r\n\r\n## Current behavior\r\n\u003c!-- Describe how the issue manifests. -->\r\nInside 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'`\r\n\r\n## Expected behavior\r\n\u003c!-- Describe what the desired behavior would be. -->\r\nRelative navigation should work normally\r\n\r\n## Minimal reproduction of the problem with instructions\r\n\u003c!--\r\nFor bug reports please provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://stackblitz.com or similar (you can use this template as a starting point: https://stackblitz.com/fork/angular-gitter).\r\n-->\r\nA stackblitz example of the issue can be seen here: https://stackblitz.com/edit/angular-gitter-k7fjds\r\n\r\n## What is the motivation / use case for changing the behavior?\r\n\u003c!-- Describe the motivation or the concrete use case. -->\r\n1. This appears to be a bug\r\n2. 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. \r\n\r\n## Additional Information\r\n\r\nIt 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.\r\n\r\n## Environment\r\n\r\n\u003cpre>\u003ccode>\r\nAngular version: 5.0.0\r\n\u003c!-- Check whether this is still an issue in the most recent Angular version -->\r\n\r\nBrowser:\r\n- [x] Chrome (desktop) version 64\r\n","author":{"url":"https://github.com/jorroll","@type":"Person","name":"jorroll"},"datePublished":"2018-03-14T12:22:01Z","url":"https://github.com/angular/angular/issues/22763"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a1245611-2e42-f4c8-17b0-464fb1de05c3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA8E:DB09F:97CEAF:C30E00:6B00F144 |
| html-safe-nonce | e760d0b3b37f2cbf4f752457594f5abb847ee75b86143de2ea230e209c056cfa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQThFOkRCMDlGOjk3Q0VBRjpDMzBFMDA6NkIwMEYxNDQiLCJ2aXNpdG9yX2lkIjoiMjI2NTI0NjA2OTU5NDA1OTA3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1ba3d96a60f46b19fb5e268bb2b9d1e78389cf8d289072bb10667b1d7d060dc3 |
| hovercard-subject-tag | issue:305136207 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/22763/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0672bba70add58849d347be84a2a6bfc4f6397565b7d0e5f94730b8c422180a9/angular/angular/issues/22763 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0672bba70add58849d347be84a2a6bfc4f6397565b7d0e5f94730b8c422180a9/angular/angular/issues/22763 |
| og:image:alt | I'm submitting a... [x] Bug report Current behavior Inside a route guard, injecting ActivatedRoute and attempting relative navigation via this.router.navigate(['../sibling'], {relativeTo: this.rout... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jorroll |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width