angular/packages/router
Andrew Scott b2790813a6 fix(router): Align RouterModule.forRoot errorHandler with provider error handler (#57050)
This change aligns the behavior of the error handler in the
`ExtraOptions` of `RouterModule.forRoot` with the error handler in
`withNavigationErrorHandler`. The changes are:

* Slightly different timing: The handler is called before the
  `NavigationError` emits
* Runs in the injection context, meaning it is more configurable at the
  config location rather than needing to assign the value to the
  `Router.errorHandler` later to get access to injectables
* Can now return `RedirectCommand` to recover from the error and
  redirect without emitting `NavigationError`
* No longer allows arbitrarily overriding return value of the navigation
  promise

BREAKING CHANGE: The `Router.errorHandler` property has been removed.
Adding an error handler should be configured in either
`withNavigationErrorHandler` with `provideRouter` or the `errorHandler`
property in the extra options of `RouterModule.forRoot`. In addition,
the error handler cannot be used to change the return value of the
router navigation promise or prevent it from rejecting. Instead, if you
want to prevent the promise from rejecting, use `resolveNavigationPromiseOnError`.

PR Close #57050
2024-08-12 09:28:08 -07:00
..
scripts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
src fix(router): Align RouterModule.forRoot errorHandler with provider error handler (#57050) 2024-08-12 09:28:08 -07:00
test fix(router): Align RouterModule.forRoot errorHandler with provider error handler (#57050) 2024-08-12 09:28:08 -07:00
testing feat(router): Add routerOutletData input to RouterOutlet directive (#57051) 2024-08-09 08:08:26 -07:00
upgrade refactor: migrate router to prettier formatting (#54318) 2024-02-08 19:17:14 +00:00
.gitignore refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
BUILD.bazel refactor(docs-infra): migrate @angular/docs from dev-infra into adev directory (#57132) 2024-07-30 15:51:26 +00:00
index.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
package.json build: update Node.js to match Angular CLI engines (#56187) 2024-06-03 18:00:46 +00:00
PACKAGE.md docs: Use new Urls to drop the docs url mapper (#55043) 2024-04-09 12:23:09 -07:00
public_api.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
README.md docs: Use new Urls to drop the docs url mapper (#55043) 2024-04-09 12:23:09 -07:00

Angular Router

Managing state transitions is one of the hardest parts of building applications. This is especially true on the web, where you also need to ensure that the state is reflected in the URL. In addition, we often want to split applications into multiple bundles and load them on demand. Doing this transparently isnt trivial.

The Angular router is designed to solve these problems. Using the router, you can declaratively specify application state, manage state transitions while taking care of the URL, and load components on demand.

Guide

Read the dev guide here.