Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeInjector breaks normal Angular DI priority #977

Open
msgoloborodov opened this issue Jan 19, 2023 · 3 comments
Open

MergeInjector breaks normal Angular DI priority #977

msgoloborodov opened this issue Jan 19, 2023 · 3 comments

Comments

@msgoloborodov
Copy link
Contributor

const mergedParentInjector = new MergeInjector(moduleInjector, parentComponentInjector);

@msgoloborodov
Copy link
Contributor Author

msgoloborodov commented Jan 19, 2023

https://angular.io/guide/hierarchical-dependency-injection#resolution-rules
Angular tries to find dependency in ElementInjector tree, if Angular doesn't find the provider in any ElementInjector hierarchies, it goes back to the element where the request originated and looks in the ModuleInjector hierarchy.
But UIView creates component with custom injector MergeInjector which firstly search token in ModuleInjector and then in ElementInjector.
For example, it will return service provided in root ModuleInjector, but it must return service provided in parent component or in lazy module (child module).
I think it should first look in all parents element injectors and only then in moduleInjector.

@msgoloborodov
Copy link
Contributor Author

PR to fix this issue: #978.

@wawyed
Copy link
Member

wawyed commented Aug 4, 2023

When is this an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants