For my application, I have a dropdown of 'Statements' which a user can select. When the user selects a specific statement, an API call is made that retrieves ways of how this data has to be displayed, called ViewOptions. The format looks as follows:
[
{
"Id": 1,
"OptionName": "Graph and table"
},
{
"Id": 3,
"OptionName": "Query results"
}
]
Now I have a different component that will be rendered when the viewoptions are loaded that should display a tab with information depending on the view options. So in this example, there is a tab where a graph and table of data have to be shown, and another tab where results of a query have to be shown.
In the tab component, I have the following HTML:
<ngb-tabset justify="justified" *ngIf="viewOptions.length">
<ngb-tab *ngFor="let vo of viewOptions" id="{{vo.Id}}">
<ng-template ngbTabTitle>{{vo.OptionName}}</ng-template>
<ng-template ngbTabContent></ng-template>
</ngb-tab>
</ngb-tabset>
So, for each viewoption, a tab will be rendered with the correct title. Now my confusion lies with how I should deal with the 'ngbTabContent' thing. Herein I want a specific component depending on the viewoption, for example if it's a "Graph and table", I have the component, for "Query results" I have the component, and so on... I am pretty new to Angular2 and I have a feeling I will have to do this with some sort of templating but the fact I have to do this dynamically depending on that 'vo' parameter in an *ngFor messes a bit with my head.