René's URL Explorer Experiment


Title: Router Resolve should have official support for UrlTree based redirection · Issue #29089 · angular/angular · GitHub

Open Graph Title: Router Resolve should have official support for UrlTree based redirection · Issue #29089 · angular/angular

X Title: Router Resolve should have official support for UrlTree based redirection · Issue #29089 · angular/angular

Description: 🚀 feature request Relevant Package @angular router Description I see that in the docs it is recommended to do the following to cancel a navigation event in a Resolve route data resolver. resolve(route: ActivatedRouteSnapshot, state: R...

Open Graph Description: 🚀 feature request Relevant Package @angular router Description I see that in the docs it is recommended to do the following to cancel a navigation event in a Resolve route data resolver. resolve...

X Description: 🚀 feature request Relevant Package @angular router Description I see that in the docs it is recommended to do the following to cancel a navigation event in a Resolve<T> route data resolver. r...

Opengraph URL: https://github.com/angular/angular/issues/29089

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Router Resolve\u003cT\u003e should have official support for UrlTree based redirection","articleBody":"# 🚀 feature request\r\n\r\n### Relevant Package\r\n@angular router\r\n\r\n### Description\r\nI see that in the [docs](https://angular.io/guide/router#!#resolve-guard) it is recommended to do the following to cancel a navigation event in a `Resolve\u003cT\u003e` route data resolver.\r\n\r\n```\r\nresolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable\u003cCrisis\u003e | Observable\u003cnever\u003e {\r\n    let id = route.paramMap.get('id');\r\n \r\n    return this.cs.getCrisis(id).pipe(\r\n      take(1),\r\n      mergeMap(crisis =\u003e {\r\n        if (crisis) {\r\n          return of(crisis);\r\n        } else { // id not found\r\n          this.router.navigate(['/crisis-center']);\r\n          return EMPTY;\r\n        }\r\n      })\r\n    );\r\n  }\r\n```\r\n While this does work it generates a pretty gnarly `NavigationCancel` event that basically says 'You broke my internal state':\r\n\r\n```\r\nNavigationCancel {id: 5, url: \"/crisis-center/4444\", reason: \"Navigation ID 5 is not equal to the current navigation id 6\"}\r\nid: 5\r\nreason: \"Navigation ID 5 is not equal to the current navigation id 6\"\r\nurl: \"/crisis-center/4444\"\r\n```\r\n\r\nThis is because we have overlapping navigation events, and the original navigation is cancelled because we essentially triggered the router's panic mode.\r\n\r\n### Describe the solution you'd like\r\nAngular 7.1 introduced the option of returning a `UrlTree` from a `canActivate`, and I think something similar should be added to `Resolve\u003cT\u003e` for feature parity.\r\n\r\nA `Resolve` may fail for many reasons, but we should have a clean option to redirect within the resolver - especially in cases where it is impossible to know the final destination until you've attempted to get the data.\r\n\r\nI think perhaps the signature of `resolve` needs to become something like :\r\n\r\n     resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable\u003cT | UrlTree\u003e | Promise\u003cT | UrlTree\u003e | T | UrlTree;\r\n\r\n### Describe alternatives you've considered\r\nYes, delving into the code showed me that I could throw an error that satisfies the `isNavigationCancelingError()` type-guard and not only would it give me a nicer `NavigationCancel` event it would also allow me to pass a `url: UrlTree` parameter which will then be navigated to on my behalf.\r\n\r\n          throw { ngNavigationCancelingError: true, url: this.router.createUrlTree(newUrl) };\r\n\r\nWhile this actually works quite well - and gives the following 'nice' event it isn't really supported since I have to use the magic internal property name - and also not every reason for aborting a Resolve is an error condition.\r\n\r\n```\r\nNavigationCancel {id: 11, url: \"/account/orders/latest\", reason: undefined}\r\nid: 11\r\nreason: undefined\r\nurl: \"/account/orders/latest\"\r\n```\r\n\r\nThe other alternative is what is suggested in the docs, but the error (`Navigation ID 5 is not equal to the current navigation id 6`) from doing that just makes it look like something is broken. \r\n\r\nI think the mechanics of this are basically already there, expecially with the new functionality in 7.1 to handle a `UrlTree`. There is also plenty of need for [such a feature](https://stackoverflow.com/questions/43097103/redirect-if-resolve-fails-angular-2) on Stackoverflow..","author":{"url":"https://github.com/simeyla","@type":"Person","name":"simeyla"},"datePublished":"2019-03-04T05:00:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/29089/angular/issues/29089"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:06820462-9002-2f59-2c01-5c42cbc254de
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCA34:12B146:638570:8CBD4E:6A62400B
html-safe-nonce1604527a2b66d7b42fe0426b2bdecb00f078c675d872a84d74a9ba3c812c71f1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTM0OjEyQjE0Njo2Mzg1NzA6OENCRDRFOjZBNjI0MDBCIiwidmlzaXRvcl9pZCI6IjUzMTE0MDc3MTY4MjA5OTIwMTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace42409915fe7c812ec239ed07660c2d8f6baa2138011f90705450ad0f75bca51
hovercard-subject-tagissue:416631206
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/29089/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9a33204d434e3f6cdf0cf590a653f6fabe22382bae9dc8919715e8f5c76066bf/angular/angular/issues/29089
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9a33204d434e3f6cdf0cf590a653f6fabe22382bae9dc8919715e8f5c76066bf/angular/angular/issues/29089
og:image:alt🚀 feature request Relevant Package @angular router Description I see that in the docs it is recommended to do the following to cancel a navigation event in a Resolve route data resolver. resolve...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesimeyla
hostnamegithub.com
expected-hostnamegithub.com
None5d6ba65d73ecc4e3394fe318d2b2f98e6f8eed4878b5421b938e20d30bde267b
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2dadc56fd5989b76a8ae7304e3aa56d0b485e5dc
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/angular/angular/issues/29089#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F29089
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F29089
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/29089
Reloadhttps://github.com/angular/angular/issues/29089
Reloadhttps://github.com/angular/angular/issues/29089
Please reload this pagehttps://github.com/angular/angular/issues/29089
angular https://github.com/angular
angularhttps://github.com/angular/angular
Notifications https://github.com/login?return_to=%2Fangular%2Fangular
Fork 27.3k https://github.com/login?return_to=%2Fangular%2Fangular
Star 101k https://github.com/login?return_to=%2Fangular%2Fangular
Code https://github.com/angular/angular
Issues 983 https://github.com/angular/angular/issues
Pull requests 170 https://github.com/angular/angular/pulls
Discussions https://github.com/angular/angular/discussions
Actions https://github.com/angular/angular/actions
Projects https://github.com/angular/angular/projects
Security and quality 24 https://github.com/angular/angular/security
Insights https://github.com/angular/angular/pulse
Code https://github.com/angular/angular
Issues https://github.com/angular/angular/issues
Pull requests https://github.com/angular/angular/pulls
Discussions https://github.com/angular/angular/discussions
Actions https://github.com/angular/angular/actions
Projects https://github.com/angular/angular/projects
Security and quality https://github.com/angular/angular/security
Insights https://github.com/angular/angular/pulse
Router Resolve should have official support for UrlTree based redirectionhttps://github.com/angular/angular/issues/29089#top
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/simeyla
simeylahttps://github.com/simeyla
on Mar 4, 2019https://github.com/angular/angular/issues/29089#issue-416631206
@angularhttps://github.com/angular
docshttps://angular.io/guide/router#!#resolve-guard
such a featurehttps://stackoverflow.com/questions/43097103/redirect-if-resolve-fails-angular-2
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.