0

I need insert a component dynamically, my problem is that I need modify the default template to insert a value as input in the tag like this:

<app-round [round]="round" #round>  </app-round>

I use ComponentFactoryResolver to insert this component in the view something like that:

@ViewChild('parent', {read: ViewContainerRef }) container: ViewContainerRef;

//  method to insert in the view is
private addComponent() {
    // check and resolve the component
    var comp = this.componentFactoryResolver.resolveComponentFactory(BirdComponent);

    // create component inside container #parent
    var birdComponent = this.container.createComponent(comp);

    // see explanations
    birdComponent.instance._ref = birdComponent;

So, this works fine but I don't know how insert the input 'round' like the app-round tag.

I need insert a lot of this round tag but with different values dynamically.

Any ideas?

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
Matias Celiz
  • 322
  • 3
  • 11

0 Answers0