Reputation: 1964
When we want the Parent component listens for child event we use the @output parameter and subscribing on the parent markup:
<my-tag (onMyEvent)="onMyEvent($event)"></my-tag>
how do I do it with ComponentResolver?
Upvotes: 5
Views: 4925
Reputation: 657416
That's not supported.
- use a shared service with components that are dynamically added using ViewContainerRef.createComponent()
or
- use the componentRef
it returns to wire inputs and outputs imperatively.
this.resolver.resolveComponent(this.type).then((factory:ComponentFactory<any>) => {
this.cmpRef = this.target.createComponent(factory);
this.cmpRef.instance.someOutput.subscribe(...)
this.cmpRef.instance.someInput = this.someInputValue;
});
Upvotes: 12