Title: Replacement for Resolve & Guard · Issue #18247 · angular/angular · GitHub
Open Graph Title: Replacement for Resolve & Guard · Issue #18247 · angular/angular
X Title: Replacement for Resolve & Guard · Issue #18247 · angular/angular
Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [x] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here...
Open Graph Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [x] Feature request [ ] Documentation issue or request [ ] Support request => P...
X Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [x] Feature request [ ] Documentation issue or request [ ] Support request ...
Opengraph URL: https://github.com/angular/angular/issues/18247
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Replacement for Resolve & Guard","articleBody":"## I'm submitting a...\r\n\u003c!-- Check one of the following options with \"x\" -->\r\n\u003cpre>\u003ccode>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[ ] Bug report \u003c!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[x] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n\u003c/code>\u003c/pre>\r\n\r\n## Current behavior\r\nThe way Guard and Resolve have to be used is very restrictive.\r\nThere are many case it make it very complicated to do simple things.\r\n\r\n## Expected behavior\r\nIntroduce a new concept to solve all theses common problems.\r\n\r\nFor example:\r\n\r\n```ts\r\nresolve: [\r\n {\r\n use: UserGuardResolver,\r\n name: user1, // store the return of the function here\r\n parameters: {\r\n id: 1,\r\n role: 'guest'\r\n }\r\n]\r\n```\r\n\r\nThis UserGuardResolver has to be able to:\r\n* store the user1 in data\r\n* cancel the route activation and redirect\r\n\r\n## What is the motivation / use case for changing the behavior?\r\n\r\n**Problem 1**: pass parameters to Resolve (or Guard) when using it multiple times (the following code does not work, just to show there is no way to pass theses parameters)\r\n```ts\r\nresolve: {\r\n user1: UserResolver(1),\r\n user2: UserResolver(2)\r\n},\r\ncanActivate:[DenyAccessForRoleGuard('guest'), DenyAccessForRoleGuard('non-granted-user')]\r\n```\r\nIn some case, we can pass parameters with data, but not when using the guard multiple times.\r\n\r\n**Problem 2**: sometimes, you want to do Guard stuff in Resolve, or Resolve stuff in Guard.\r\nFor example, I make a http call in a guard to check some stuff, then I want to make it available in the component, so I store it in data.\r\n\r\nSometimes, I get a 401 during Resolve http call, so I want to cancel the route activation and redirect.\r\n\r\nNot sure about what is the best solution, but we should make it easier to integrate both concepts.\r\n\r\n**Problem 3**: there are no way to order or chain easily the guards and resolve\r\n@see for example https://github.com/angular/angular/issues/18092 and https://github.com/angular/angular/issues/15032\r\n\r\n## Environment\r\n\r\n\u003cpre>\u003ccode>\r\nAngular version: 4.3.0\r\n\u003c/code>\u003c/pre>\r\n","author":{"url":"https://github.com/Toub","@type":"Person","name":"Toub"},"datePublished":"2017-07-20T10:14:50Z","url":"https://github.com/angular/angular/issues/18247"}
| 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:94917b34-83dd-2f9b-faad-ada456408356 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 861A:38E318:38007:4688F:6B00F3CE |
| html-safe-nonce | 0d908205f918d2c8c93c21a2c2fe5a4e932943cacd5ef24ceb9cb7a2c779ccd7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjFBOjM4RTMxODozODAwNzo0Njg4Rjo2QjAwRjNDRSIsInZpc2l0b3JfaWQiOiIzOTI4ODk5MDA0OTc2OTU2OTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f2e7de97c2a520054235c51a7c9d6bb6ea2165423f0c64e54550b2155f7dcf93 |
| hovercard-subject-tag | issue:244312078 |
| 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/18247/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86c41e4369b70d41f066d946e345efb940b6cef8b4a36aa1b167663a10595800/angular/angular/issues/18247 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86c41e4369b70d41f066d946e345efb940b6cef8b4a36aa1b167663a10595800/angular/angular/issues/18247 |
| og:image:alt | I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report [x] Feature request [ ] Documentation issue or request [ ] Support request => P... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Toub |
| 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