Im using HTML and Angular (ts)
I tried to obtain something like this dynamically because the length of data can change and i dont want to use innerHTML :
ListAverage1 | ListAverage2 |
---|---|
1 | 12 |
2 | 13 |
3 | 14 |
4 | 15 |
5 | 16 |
6 | 17 |
7 | 18 |
8 | 19 |
From this object:
let average = { "listAverage1": [1,2,3,4,5,6,7,8], "listAverage2": [12,13,14,15,16,17,18,19] }
I tried this but nothing appeared in my table:
<table class="table table-hover table-bordered">
<ng-container matColumnDef="average1">
<th class="large8" mat-mdc-header-cell *matHeaderCellDef> ListAverage1 </th>
<tr *ngFor = "let average of this.listAverage.listAverage1">
<td>average</td>
</tr>
</ng-container>
<ng-container matColumnDef="average2">
<th class="large8" mat-mdc-header-cell *matHeaderCellDef> ListAverage2 </th>
<tr *ngFor = "let average2 of this.listAverage.listAverage2">
<td>average2</td>
</tr>
</ng-container>
</table>
Thanks for your help
2
Answers
You are not printing the result of the variable.
Should be like this
please check stackBlitz
Demo