0

I need to dynamically insert properties into third-party components. I get an object with the settings and I need to put it in the component, but the individual properties set themselves from that object. Key and value. Is it possible?

for eaxample:

export class SomeComponent {
   @input Prop1;
   @input Prop2;
}


export class MainComponent {
   someObj = {Prop1: "Value1", Prop2: "Value2"};
   someArray = [1,2];

}

in MainComponent Template:

i cant do that:

<div *ngFor="let item of someArray>
  <some-component prop1="value1" prop2="value2"></some-component>
</div>

but thats how I need it

<div *ngFor="let item of someArray>
  <some-component {{someObj}}></some-component>
</div>

I will need to dynamically list the components and insert some settings that can always be different. Sorry for english. Thanks for answers :)

angular version: 8.2.7

0 Answers0