У меня есть массив, который содержит: id и содержимое.
dashboard.component.ts
this.tablePresetColumns = [{id: 1,content: 'Username'},{id: 2,content:'Status'}];
this.tablePresetData = [[{id: 1, content: "Budi Kurniawan"},{id: 2, content: "Busy"}]]
До сих пор я пробовал эти:
Dashboard.component.html
<table class="table" [ngClass]="modes">
<thead *ngIf="columns">
<tr>
<th *ngFor="let col of tablePresetColumns">
{{col.content}}
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of tablePresetData ">
<td *ngFor="let cell of row[i]"> {{cell.content}}
</td>
<td *ngFor="let cell of row[i]">
<span class ="dot" [ngClass]="{
'dot-yellow' : cell.content == 'Busy',
'dot-green' : cell.content == 'Idle',
'dot-red' : cell.content == 'Overload'}">
</span>
</td>
</tr>
</tbody>
</table>
Как получить доступ к данным моего массива в файле component.ts, чтобы я мог отображать данные в виде таблицы?Я пытаюсь *ngFor
, но все еще не могу ничего показать.