Jedi Schmedi
Jedi Schmedi

Reputation: 818

Angular 4, insert multiple components

Im making an application in angular 4 where the users can choose which graphs that should show in thier view. They should be able to pick X nr graph and they should be able to show same graph twice if they choose to.

So I was thinking to build a string of my components:

this.test = '<app-overview [price]=this.price [selectedSymbol]=this.selectedSymbol></app-overview>'

and then render in in the html. Since its possible to choose multiple graphs I want to loop over them with an ng-for. What is the best practice for this in angular 4?

Upvotes: 1

Views: 1787

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 341

insert component dynamically(https://angular.io/guide/dynamic-component-loader) and you can pass input to them dynamically too.

Upvotes: 1

Related Questions