Title: Retrieve all route segments configuration by URL · Issue #15750 · angular/angular · GitHub
Open Graph Title: Retrieve all route segments configuration by URL · Issue #15750 · angular/angular
X Title: Retrieve all route segments configuration by URL · Issue #15750 · angular/angular
Description: I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [x] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/an...
Open Graph Description: I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [x] feature request [ ] support request => Please do not submit support request...
X Description: I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [x] feature request [ ] support request => Please do not su...
Opengraph URL: https://github.com/angular/angular/issues/15750
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Retrieve all route segments configuration by URL","articleBody":"\u003c!--\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION WE MIGHT CLOSE YOUR ISSUE WITHOUT INVESTIGATING\n-->\n\n**I'm submitting a ...** (check one with \"x\")\n```\n[ ] bug report => search github for a similar issue or PR before submitting\n[x] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Current behavior**\n\u003c!-- Describe how the bug manifests. -->\nThere is no clear way to get the configuration, see http://stackoverflow.com/q/43143621/1990451.\n\nGiven a URL, e.g. `/path/path2/path3/123;sdf=df` and a routes configuration:\n\n { path: 'path', data: { g: 'h' }, children: [\n { path: 'path2', data: { c: 'd' }, children: [\n { path: 'something', component: TestpageComponent, data: { a: 'b' } },\n { path: 'path3/create', component: TestpageComponent, data: { b: 'c' } },\n { path: 'path3/:id', component: TestpageComponent, data: { b: 'c' } },\n ] }\n ] },\n\nIt would be useful to find an actual configuration for all the segments in order to e.g. get a result set of all `data` parameters on all levels (each segment of the url).\n\nIt is possible to split the URL to the segments by e.g.\n\n console.log(this.router.parseUrl(url));\n\nor to be more precise\n\n console.log(this.router.parseUrl(url).root.children['primary'].segments);\n\nwhich will return \n\n [{\"path\":\"path\",\"parameters\":{}},{\"path\":\"path2\",\"parameters\":{}},{\"path\":\"and\",\"parameters\":{}},{\"path\":\"123\",\"parameters\":{\"sdf\":\"df\"}}]\n\nSo, splitting the URL into segments is not a problem. However it does not provide the configuration for each segment. One can get the actual configuration for all the routes with\n\n console.log(this.router.config);\n\nIt's possible to go with the parsed segments through the configuration tree and resolve the branch (and it's not that complicated actually), but it can cause troubles e.g. while resolving `:id` against `create` segment. So, it would be cool to use the *router's* way of resolving the configuration.\n\n**Expected behavior**\n\u003c!-- Describe what the behavior would be without the bug. -->\nI would expect a method on a `Router` service that returns an array of all the configurations available for a given URL. E.g.\n\n router.configurationByUrl('/path/path2/path3/123;sdf=df')\n // returns [\n // { path: 'path', data: { g: 'h' }, children: [...] },\n // { path: 'path2', data: { c: 'd' }, children: [...] },\n // { path: 'path3/:id', component: TestpageComponent, data: { b: 'c' } }\n //], \n\n**Minimal reproduction of the problem with instructions**\n\u003c!--\nIf the current behavior is a bug or you can illustrate your feature request better with an example, \nplease provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\nhttps://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\n-->\n\n\n**What is the motivation / use case for changing the behavior?**\n\u003c!-- Describe the motivation or the concrete use case -->\nImagine I have a 50% of the URLs protected by some guard (e.g. only logged in users could go there) and other 50% is not protected (displayed for everybody). So, on the navigation menu level (outside of the `router-outlet`) I want to display only the links which are relevant for the current user, so I need to know which routes are protected by the guard. Guards / data / whatever is just a particular case of the problem.\n\n**Please tell us about your environment:**\n\u003c!-- Operating system, IDE, package manager, HTTP server, ... -->\n\n* **Angular version:** 2.0.X / 4.0.X\n\u003c!-- Check whether this is still an issue in the most recent Angular version -->\n\n* **Browser:** [all]\n\u003c!-- All browsers where this could be reproduced -->\n \n* **Language:** [all]\n\n* **Node (for AoT issues):** `node --version` = X","author":{"url":"https://github.com/smnbbrv","@type":"Person","name":"smnbbrv"},"datePublished":"2017-04-04T07:43:16Z","url":"https://github.com/angular/angular/issues/15750"}
| 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:75647bf7-ddd9-f942-79c6-89e8fbe24ceb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E692:DB09F:1287069:17A91CB:6B0124A8 |
| html-safe-nonce | 08a90f6e7d737a6d6c5dfca5c3d93a1cd017196383be51a352d00297f927fd61 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjkyOkRCMDlGOjEyODcwNjk6MTdBOTFDQjo2QjAxMjRBOCIsInZpc2l0b3JfaWQiOiI2OTgxNjU3MzcwODE2NDg4NjE2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 57b96bb0323cacd7ab752bec0e46116263cf25fca8367a51aa869bd991096c2d |
| hovercard-subject-tag | issue:219165693 |
| 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/15750/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a880cd40d0da0527af33554b0cf031ab550c2c936f6a2698d475c78e148974fb/angular/angular/issues/15750 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a880cd40d0da0527af33554b0cf031ab550c2c936f6a2698d475c78e148974fb/angular/angular/issues/15750 |
| og:image:alt | I'm submitting a ... (check one with "x") [ ] bug report => search github for a similar issue or PR before submitting [x] feature request [ ] support request => Please do not submit support request... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | smnbbrv |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width