Replies: 2 comments
-
I'm starting this thread again because I have the same problem and I can't find many resources on the subject. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, its possible to do. Example createEnvinronmentInjector([
provideState(),
provideEffects()
], parentInjector); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We have an Angular app that we are converting to standalone. After some trial and error everything went fine, except for a single case.

We have a component that asks the user for some data confirmation. This happens usually every two years. Clearly we want to load this component only when needed.
The component itself is loaded inside a dialog, but it has some state and some effects. Now, to provide state and effects I need an EnvironmentInjector (as ProvideEffects returns an EnvironmentProvider).
I can't use providers array in bootstrapApplication as it is global, and I haven't a route, as the component is loaded inside a dialog, no matter what is the page selected.
the angular guide (https://angular.io/guide/standalone-components#environment-injectors) says
So I think the only option left is to create an EnvironmentInjector with CreateEnvironmentInjector. This, from what I have understood, would imply injecting an ApplicationRef to get the root injector and pass it as parent to CreateEnvironmentInjector.
I don't know if this is possible with provideEffects, or if there is a canonical way to do this, or simply a better way.
Could someone point me in the right direction?
Beta Was this translation helpful? Give feedback.
All reactions