Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output parameter in dynamic components

Tags:

angular

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?

like image 366
Avi Avatar asked Jun 07 '16 15:06

Avi


People also ask

What are output parameters?

Output parameters are the parameters that are fetched from the response of a service call. These are formatted according to the attributes you configure for the output before displaying on the device. The service parameters have a scope and data type attached to them.

What is output parameter in Outsystems?

An Output Parameter allows you to return computed values from an action, process, or process flow element.

What is the dynamic component?

What dynamic components are. Dynamic means, that the components location in the application is not defined at buildtime. That means, that it is not used in any angular template. Instead, the component is instantiated and placed in the application at runtime.


1 Answers

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;
});
like image 184
Günter Zöchbauer Avatar answered Sep 22 '22 12:09

Günter Zöchbauer