feat(common): add support for a custom EnvironmentInjector to NgComponentOutlet directive#54764
feat(common): add support for a custom EnvironmentInjector to NgComponentOutlet directive#54764reey wants to merge 2 commits intoangular:mainfrom
Conversation
|
Hi, I'm curious what happens when you pass the environment injector as the injector input ? Could it replace the environment if it's an environment Injector ? |
When passing the environment injector as the injector input we are able to inject the services provided in the remote module, but we are then unable to access the component tree via DI, so e.g. we can't inject a parent component. |
|
@JeanMeche sorry if I might be a bit impatient, but is there anything I've missed to get this PR reviewed? 😅 |
Offline discussion about needing more clarification.
|
@reey We're unclear on this use-case as it seems a bit unusual. Can you clarify why this is a need? |
@thePunderWoman We are using the Module Federation feature of webpack to dynamically load further angular modules into our shell application. The remote modules are then instantiated using In order to instantiate these components as part of our shell application, we need to use the injector of the remote module since it might otherwise not have access to e.g. services that were only provided as part of the remote module the component was part of. To do so, we would need to have the option to also provide a different environment injector via the NgComponentOutlet directive. |
…nentOutlet directive Signed-off-by: Tristan Bastian <tristan.bastian@cumulocity.com>
…NgComponentOutlet directive
mmalerba
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
|
This PR was merged into the repository by commit 58aedc3. The changes were merged into the following branches: main |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently the
NgComponentOutletdirective does not provide a way to specify a customEnvironmentInjector.For our usecase we are using webpack Module Federation to load a remote module into our shell application. This remote module uses a different
EnvironmentInjector, which is a child of the shellsEnvironmentInjector. Without being able to specify theEnvironmentInjectorof the remote module when creating the component, the component is unable to use dependency injection for e.g. services provided as part of the remote module.Issue Number: N/A
What is the new behavior?
This PR adds an additional
Inputto theNgComponentOutletdirective to provide a customEnvironmentInjector.Does this PR introduce a breaking change?
Other information