You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
Having a component inject a service via @Component({providers: [...], ...}) doesn't trickle down to child elements, if the elements are instantiated as web-components via Angular Elements.
Expected behavior
Elements created via Angular Elements should inherit the provided dependencies.
Minimal reproduction of the problem with instructions
However, this doesn't work. At runtime, you get an error:
Uncaught Error: StaticInjectorError(AppModule)[BarComponent -> ContextProvider]:
StaticInjectorError(Platform: core)[BarComponent -> ContextProvider]:
NullInjectorError: No provider for ContextProvider!
What is the motivation / use case for changing the behavior?
I'm using Angular Elements as a way to get dynamic component generation. Having Element Injectors work in this environment is essential for this use case.
This is works as intended (or more accurately, this is not possible with Elements) - Elements will share the NgModule injector, but they will not share injectors hierarchically (effectively, each element is a completely isolated island, and it's parent is the NgModule injector (or whatever injector you pass into createCustomElement)
I'm submitting a...
Current behavior
Having a component inject a service via
@Component({providers: [...], ...})
doesn't trickle down to child elements, if the elements are instantiated as web-components via Angular Elements.Expected behavior
Elements created via Angular Elements should inherit the provided dependencies.
Minimal reproduction of the problem with instructions
Full repo: https://github.com/fr0/angular-elements-test
Summary:
FooComponent
is registered with Angular Elements ascustom-foo
.BarComponent
is registered with Angular Elements ascustom-bar
.FooComponent
provides a service,ContextProvider
.BarComponent
needs this service.The components are instantiated dynamically via web-components in the following manner:
However, this doesn't work. At runtime, you get an error:
What is the motivation / use case for changing the behavior?
I'm using Angular Elements as a way to get dynamic component generation. Having Element Injectors work in this environment is essential for this use case.
Environment
The text was updated successfully, but these errors were encountered: