Title: Access failed ActivatedRouteSnapshot in NavigationError · Issue #27626 · angular/angular · GitHub
Open Graph Title: Access failed ActivatedRouteSnapshot in NavigationError · Issue #27626 · angular/angular
X Title: Access failed ActivatedRouteSnapshot in NavigationError · Issue #27626 · angular/angular
Description: 🚀 Access failed ActivatedRouteSnapshot in NavigationError Relevant Package This feature request is for @angular/router. Specifically, /packages/router/src/router.ts. Description I have the following scenario: user clicks a link to go to ...
Open Graph Description: 🚀 Access failed ActivatedRouteSnapshot in NavigationError Relevant Package This feature request is for @angular/router. Specifically, /packages/router/src/router.ts. Description I have the followin...
X Description: 🚀 Access failed ActivatedRouteSnapshot in NavigationError Relevant Package This feature request is for @angular/router. Specifically, /packages/router/src/router.ts. Description I have the followin...
Opengraph URL: https://github.com/angular/angular/issues/27626
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Access failed ActivatedRouteSnapshot in NavigationError","articleBody":"# 🚀 Access failed ActivatedRouteSnapshot in NavigationError\r\n\r\n### Relevant Package\r\n\u003c!-- Can you pin-point one or more @angular/* packages the are relevant for this feature request? -->\r\n\u003c!-- ✍️edit: --> This feature request is for @angular/router. Specifically, /packages/router/src/router.ts.\r\n\r\n### Description\r\nI have the following scenario:\r\n\r\n1. user clicks a link to go to a new page\r\n1. one of the resolvers for that page fails with a very specific error (let's say, missing permissions)\r\n1. I listen on NavigationError events\r\n1. I catch the NavigationError event. It contains the error raised in step 2 and the URL the user was trying to reach.\r\n1. I'd like to be able to configure (in the route configuration) where to redirect the user when this specific error occurs. But I don't have the handle to ActivatedRouteSnapshot for the page the user was trying to reach, and so I cannot access its \"data\" property where I wrote the configuration.\r\n\r\nA sample route configuration could look like this:\r\n\r\n @NgModule({\r\n ...\r\n RouterModule.forChild([{\r\n data: {\r\n permissionConfig: {...}\r\n }}])})\r\n\r\n### Describe the solution you'd like\r\nIdeally, I'd like the failed ActivatedRouteSnapshot to be a field of NavigationError. It's important for it to be the \"leaf\" ActivatedRouteSnapshot, not the root one, as it's in the leaf where I put my permissionConfig.\r\n\r\n### Describe alternatives you've considered\r\nCurrently I'm using the following workaround: I have a \"fake\" route guard, with a canActivate call that always returns of(true), but remembers its arguments (ActivatedRouteSnapshot and RouterStateSnapshot) on \"global\" variables that I can access later when handling the NavigationError elsewhere. I'm also clearing this global state every NavigationStart so that there's no risk of using the wrong snapshot later.\r\n\r\nThe downside of the workaround is that I have to add the fake guard to every @NgModule that uses permissionConfig. If I forget to do it, it doesn't work. And I cannot add my fake guard to the root @NgModule (to RouterModule.forRoot), because then the ActivatedRouteSnapshot I receive is the root snapshot and I have no means of knowing which of its children I should descend to to find my configuration (there can be multiple children because of outlets).","author":{"url":"https://github.com/dzinxed","@type":"Person","name":"dzinxed"},"datePublished":"2018-12-12T14:55:15Z","url":"https://github.com/angular/angular/issues/27626"}
| 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:278b7898-9a2e-b190-ba59-8c77dc4f4aa8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1E8:14ECB:AAD4C0:DAA39A:6B00F551 |
| html-safe-nonce | 02cc47b5b5caef379f0165fbf8d0ff84e89275498ee4d4b8c91865faea5325f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUU4OjE0RUNCOkFBRDRDMDpEQUEzOUE6NkIwMEY1NTEiLCJ2aXNpdG9yX2lkIjoiNjk2ODAzNzAwODk1MjI1MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 57783cc140dd28dcf88b962861e44ec599d10959fe10c60b39637c4d7da2b903 |
| hovercard-subject-tag | issue:390262149 |
| 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/27626/issue_layout |
| twitter:image | https://opengraph.githubassets.com/427cdb7efc7577594fed52af6bab1011d69ad82a702295f1607cc25826c0b86c/angular/angular/issues/27626 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/427cdb7efc7577594fed52af6bab1011d69ad82a702295f1607cc25826c0b86c/angular/angular/issues/27626 |
| og:image:alt | 🚀 Access failed ActivatedRouteSnapshot in NavigationError Relevant Package This feature request is for @angular/router. Specifically, /packages/router/src/router.ts. Description I have the followin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dzinxed |
| 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