angular/packages/router
Andrew Kushnir 9894278e71 fix(core): make ActivatedRoute inject correct instance inside @defer blocks (#55374)
`RouterOutlet` uses a unique injector logic that returns a value that correspond to the `ActivatedRoute` token dynamically. This logic breaks when a component/directive/pipe that injects the `ActivatedRoute` is located within a `@defer` block, because defer creates an `EnvironmentInjector` instance, which doesn't have that dynamic logic.

We've added some special handling of the `OutletInjector` in one of the previous commits, but it was incomplete and it was not covering cases when different routes use the same component. This commit updates defer logic to re-establish this dynamic behavior for `ActivatedRoute` by creating an instance of the `OutletInjector` when a parent injector was also an instance of `OutletInjector`.

This fix is a short-term solution and longer term we should find a way to achieve the dynamic behavior that Router relies on, but without adding a special case logic into defer.

Resolves #54864.

PR Close #55374
2024-04-22 12:01:36 -07:00
..
scripts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
src fix(core): make ActivatedRoute inject correct instance inside @defer blocks (#55374) 2024-04-22 12:01:36 -07:00
test feat(router): withNavigationErrorHandler can convert errors to redirects (#55370) 2024-04-17 15:53:02 -07:00
testing docs(router): deprecate RouterTestingModule (#54466) 2024-02-20 09:33:16 -08: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 build: configure cross-pkg resolution for api extraction (#52499) 2024-01-05 11:27:34 -08: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 engines version to be more explicate about v20 support (#52448) 2023-10-31 14:18:36 -07: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.