Angular 5-仅通过更改HTML格式来垂直显示表格



我试图通过只修改HTML文件将水平表翻转为垂直表。

以下是我目前正在处理的实时代码:https://stackblitz.com/edit/angular-zdame7?file=src%2Fapp%2Fapp.component.ts

阵列:

public header: Array<string>;
public colors: Array<string>;
public cars: Array<string>;
public numbers: Array<string>;
header = {"COLORS", "CARS", "NUMBERS"};
colors= {"Blue", "Red", "Yellow"}
cars= {"Lambo", "Porsche", "Mercedes"}
numbers= {"1", "2", "3"}

预期结果:

COLORS   CARS     NUMBERS
Blue     Lambo      1
Red      Porsche    2
Yellow   Mercedes   3

试试这个

<table>
<thead>
<tr>
<th *ngFor="let head of _types.header"> {{head}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let m of _types.colors">
<td>
{{m}}
</td>
</tr>
</tbody>
</table>

最新更新