Angular 5-仅更改HTML格式即可垂直显示表格

时间:2018-07-12 15:57:25

标签: angular

我试图仅通过修改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

1 个答案:

答案 0 :(得分:0)

尝试一下

<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>