Skip to content

refactor(router): Only create the Route injector when the path matches - #45990

Closed
atscott wants to merge 1 commit into
angular:mainfrom
atscott:onlyCreateRouteInjectorOnMatch
Closed

atscott wants to merge 1 commit into
angular:mainfrom
atscott:onlyCreateRouteInjectorOnMatch

Conversation

@atscott

@atscott atscott commented May 13, 2022

Copy link
Copy Markdown
Contributor

Currently, the Router will create the EnvironmentInjector for a
Route with providers as soon as it attempts to match segments to
the Route. Instead, this change updates the logic to only create the
injector once we have confirmed that the Route matches. Note that this
will include partial matches where the final navigation still fails with
a "cannot match any routes to segment" error. We need to maintain the
injector hierarchy so we still need to create parent injectors before
descending into the child routes and determining if there is a full
match or just a partial one.

resolves #45988

@atscott atscott added area: router target: rc This PR is targeted for the next release-candidate labels May 13, 2022
@ngbot ngbot Bot added this to the Backlog milestone May 13, 2022
Currently, the `Router` will create the `EnvironmentInjector` for a
`Route` with `providers` as soon as it _attempts_ to match segments to
the `Route`. Instead, this change updates the logic to only create the
injector once we have confirmed that the `Route` matches. Note that this
will include partial matches where the final navigation still fails with
a "cannot match any routes to segment" error. We need to maintain the
injector hierarchy so we still need to create parent injectors before
descending into the child routes and determining if there is a full
match or just a partial one.

resolves angular#45988
@atscott
atscott force-pushed the onlyCreateRouteInjectorOnMatch branch from 5ee17b8 to 3b974e9 Compare May 13, 2022 17:39
@atscott

atscott commented May 13, 2022

Copy link
Copy Markdown
Contributor Author

presubmit

@atscott atscott added the action: merge The PR is ready for merge by the caretaker label May 13, 2022
@jessicajaniuk

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit 4d2e006.

jessicajaniuk pushed a commit that referenced this pull request May 13, 2022
…hes (#45990)

Currently, the `Router` will create the `EnvironmentInjector` for a
`Route` with `providers` as soon as it _attempts_ to match segments to
the `Route`. Instead, this change updates the logic to only create the
injector once we have confirmed that the `Route` matches. Note that this
will include partial matches where the final navigation still fails with
a "cannot match any routes to segment" error. We need to maintain the
injector hierarchy so we still need to create parent injectors before
descending into the child routes and determining if there is a full
match or just a partial one.

resolves #45988

PR Close #45990
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: router target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENVIRONMENT_INITIALIZER is eagerly loaded

3 participants