This bit of code is problematic for several reasons: 1. AngularJS-specific handling should not exist in core router code if it can be avoided. It's not something that should complicated the code long-term 2. It causes URL flickering (the `replace: /` really does happen and can be observed) 3. The original intent was likely for the URL to not actually change; since the Router only initially supported 'deferred' navigations, this would _usually_ be the case. 4. It actually causes observers of URL changes more problems in handling changes because the router is already about to process another navigation request. Notice that when using `'computed'` restoration logic, we do not reset the URL because it would cause another location change event and conflict with the new navigation. 5. It only resets the browser URL but does nothing to sync the rest of the internal state of the router. 6. It makes guards which call `router.navigate()` behave _slightly_ differently than guard which return `UrlTree`. Guards which return `UrlTree` do not reset the URL, but instead just trigger a new navigation. 7. It resets the entire URL rather than just the portion that the `UrlHandlingStrategy` is configured to handle. Theoretically, the Router could be configured to only handle a part of the URL so failed navigations should not reset parts it is not configured to touch. Note that this is actually a problem in other places in the router as well where `resetState` is not called before `resetUrlToCurrentUrlTree`. As a nice benefit, when `urlUpdateStrategy` is set to `'eager'`, this makes #17004 possible. BREAKING CHANGE: The router will no longer replace the browser URL when a new navigation cancels an ongoing navigation. This often causes URL flicker and was only in place to support some AngularJS hybrid applications. Hybrid applications which rely on the `navigationId` being present on initial navigations that were handled by the Angular router should instead subscribe to `NavigationCancel` events and perform the `location.replaceState` themselves to add `navigationId` to the Router state. In addition, tests which assert `urlChanges` on the `SpyLocation` may need to be adjusted to account for the `replaceState` which is no longer triggered. PR Close #43496 |
||
|---|---|---|
| .circleci | ||
| .devcontainer | ||
| .github | ||
| .husky | ||
| .ng-dev | ||
| .vscode | ||
| .yarn | ||
| aio | ||
| docs | ||
| goldens | ||
| integration | ||
| modules | ||
| packages | ||
| scripts | ||
| third_party | ||
| tools | ||
| .bazelignore | ||
| .bazelrc | ||
| .bazelversion | ||
| .clang-format | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .gitmessage | ||
| .mailmap | ||
| .npmrc | ||
| .nvmrc | ||
| .prettierrc | ||
| .pullapprove.yml | ||
| .yarnrc | ||
| browser-providers.conf.js | ||
| BUILD.bazel | ||
| CHANGELOG.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| gulpfile.js | ||
| karma-js.conf.js | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| renovate.json | ||
| test-events.js | ||
| test-main.js | ||
| tsconfig-tslint.json | ||
| tslint.json | ||
| WORKSPACE | ||
| yarn.lock | ||
| yarn.lock.readme.md | ||
Angular - The modern web developer's platform.
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.
Contributing Guidelines
·
Submit an Issue
·
Blog
Documentation
Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.
Advanced
Development Setup
Prerequisites
- Install Node.js which includes Node Package Manager
Setting Up a Project
Install the Angular CLI globally:
npm install -g @angular/cli
Create workspace:
ng new [PROJECT NAME]
Run the application:
cd [PROJECT NAME]
ng serve
Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.
Quickstart
Ecosystem
Changelog
Learn about the latest improvements.
Upgrading
Check out our upgrade guide to find out the best way to upgrade your project.
Contributing
Contributing Guidelines
Read through our contributing guidelines to learn about our submission process, coding rules and more.
Want to Help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.
Code of Conduct
Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.
Community
Join the conversation and help the community.
Love Angular? Give our repo a star ⭐ ⬆️.