In my new project, I am utilizing angular. I am curious about how to optimize this code snippet with a more elegant approach using just one *ngFor directive.
<table>
<tr>
<th *ngFor="let distribution of monthDistribution ">{{distribution.month}}</th>
</tr >
<tr>
<th *ngFor="let distribution of monthDistribution ">{{distribution.hc}}</th>
</tr>
</table>
The array monthDistribution is structured as follows :
[{month : "1", hc :"15.2"},...,{month : "12", hc :"19.2"}]
Essentially, I aim to have only one table header displaying all months and one table row showcasing the corresponding hc values. Even though altering the data format by using the month value as the key for hc is an option, I fail to see how it would address my issue.
Thank you very much.