Angular 角度5-仅通过更改HTML格式垂直显示表格
我试图通过修改HTML文件将水平表翻转为垂直表 以下是我目前正在编写的实时代码: 阵列:Angular 角度5-仅通过更改HTML格式垂直显示表格,angular,Angular,我试图通过修改HTML文件将水平表翻转为垂直表 以下是我目前正在编写的实时代码: 阵列: public header: Array<string>; public colors: Array<string>; public cars: Array<string>; public numbers: Array<string>; header = {"COLORS", "CARS", "NUMBERS"}; colors= {"Blue", "Re
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"}
试试这个
<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>
{{head}}
{{m}}
这是一个与css相关的问题,与HTMLoh无关,你能告诉我如何在css中处理这个问题吗?如果你想达到@yer post这样的效果,那就对了。我认为你有4个“标签”,你想以垂直的方式显示它们,所以这一个你需要css。如果你只需要有一个包含行和列的表,答案是正确的。我刚刚更新了一个动态的方式来显示一个表,其中包含我当前的类/服务设置,以及一个角度组件,或者一些可以让我的生活更简单的更复杂的表。我希望能够用自己的数组填充每一列,我不明白你想得到什么。请在问题中展示你真正想要的样本我已经更新了主要主题。举一个我想要的例子。你如何用这个方法添加第二列?这就是我在添加额外数组之前的情况。您在OP中发布了与我相同的链接。您是否为每个列提供了不同的数组?
<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>