Title: URL Matcher to allow service injection, to allow two routes with same path to be selected based on criteria. · Issue #34231 · angular/angular · GitHub
Open Graph Title: URL Matcher to allow service injection, to allow two routes with same path to be selected based on criteria. · Issue #34231 · angular/angular
X Title: URL Matcher to allow service injection, to allow two routes with same path to be selected based on criteria. · Issue #34231 · angular/angular
Description: 🚀 feature request Relevant Package This feature request is for @angular/router Description Currently we have 2 levels of authorisation in our app: Super admin and Organisation Admin. When those users login via /auth/login the are authent...
Open Graph Description: 🚀 feature request Relevant Package This feature request is for @angular/router Description Currently we have 2 levels of authorisation in our app: Super admin and Organisation Admin. When those use...
X Description: 🚀 feature request Relevant Package This feature request is for @angular/router Description Currently we have 2 levels of authorisation in our app: Super admin and Organisation Admin. When those use...
Opengraph URL: https://github.com/angular/angular/issues/34231
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"URL Matcher to allow service injection, to allow two routes with same path to be selected based on criteria.","articleBody":"# 🚀 feature request\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\r\n\r\n\r\n### Description\r\nCurrently we have 2 levels of authorisation in our app: Super admin and Organisation Admin.\r\nWhen those users login via `/auth/login` the are authenticated and then the logic redirects to the root `/`.\r\nOn the route path (''), I have 2 child routes, both using an UrlMatcher instead of a path.\r\n```\r\n{\r\n path: '',\r\n children: [\r\n {\r\n matcher: SuperAdminMatcher\r\n loadChildren: \u003csuper admin module>\r\n },\r\n {\r\n matcher: OrgAdminMatcher\r\n loadChildren: \u003cOrg admin module>\r\n }\r\n ]\r\n```\r\n\r\nThose matcher functions require to know what user was logged in via the AuthService. However, other then looking in my LocalStorage and get my JWT, there is no way for me to access the AuthService because I can't inject that service in the Matchers.\r\nSo my matcher can never reject based on AuthState.\r\n\r\nI ideally want to offer to paths:\r\nSuperadmin:\r\n`/organisation/list`\r\n`/organisation/ORG NAME/post/list` \u003c- super admin opening an Organisation\r\n\r\nOrg admin:\r\n`/post/list`\r\n`/post/edit/\u003cguid>`\r\n\r\nSo unfortunately I have to use to different path names to make this work, and that makes the path unnecessary long, like `http://localhost:4200/superadmin/organisation/Bramble-Cay-College/post/list\r\n\r\n### Describe the solution you'd like\r\n\u003c!-- ✍️--> If you have a solution in mind, please describe it.\r\nAllow for Injection of Providers in the Matcher. This way we can create a more advanced matcher. It is kinda like Resolve, however Resolve is currently happening after the Path or Url has been matched.\r\n\r\n\r\n### Describe alternatives you've considered\r\n\u003c!-- ✍️--> Have you considered any alternative solutions or workarounds?\r\nThe only real workaround I can find is using different path names, or using a wrapper component.\r\nHowever, I want each child to lazy load a Module, and I create a RootComponent, and load either the SuperAdminComponent or the OrgAdminComponent via *ngIf, it wouldn't be lazy loaded.","author":{"url":"https://github.com/mattiLeBlanc","@type":"Person","name":"mattiLeBlanc"},"datePublished":"2019-12-04T13:01:40Z","url":"https://github.com/angular/angular/issues/34231"}
| 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:3ffea979-febc-790b-ae75-63f8b6c354f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B9A:311640:7EFA9A:A2D7A2:6B00E7FD |
| html-safe-nonce | 21dcca106ed5a57de57f7d0e924992ae9de4f192a07833645899d4ad04c088c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjlBOjMxMTY0MDo3RUZBOUE6QTJEN0EyOjZCMDBFN0ZEIiwidmlzaXRvcl9pZCI6IjQ3Mzg4NTkzNzkwODY5MTE0ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e47ca8e0c6bdeaa93f7482111276a673eadbc31acc24943384e70b543066ee58 |
| hovercard-subject-tag | issue:532669457 |
| 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/34231/issue_layout |
| twitter:image | https://opengraph.githubassets.com/22eb4db824754a6b14756ae85deb24c728499e08a118a93716d5f574dee181c4/angular/angular/issues/34231 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/22eb4db824754a6b14756ae85deb24c728499e08a118a93716d5f574dee181c4/angular/angular/issues/34231 |
| og:image:alt | 🚀 feature request Relevant Package This feature request is for @angular/router Description Currently we have 2 levels of authorisation in our app: Super admin and Organisation Admin. When those use... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mattiLeBlanc |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width