【发布时间】:2018-12-24 13:46:33
【问题描述】:
我从 api 获取字符串数组并需要在表中显示它们(word1、word2、word3 等)。我不知道具体会是多少。表中的列数应为 5,行数取决于此数组。
<tr>
<th><a href="#">Cell 1</a></th>
<th><a href="#">Cell 2</a></th>
<th><a href="#">Cell 3</a></th>
<th><a href="#">Cell 4</a></th>
<th><a href="#">Cell 5</a></th>
</tr>
<tr>
<th><a href="#">Cell 6</a></th>
<th><a href="#">Cell 7</a></th>
<th><a href="#">Cell 8</a></th>
<th><a href="#">Cell 9</a></th>
<th><a href="#">Cell 9</a></th>
</tr>
如果有 20 个项目 - 应该是 4 行。我不知道如何开始新行。 示例是按行填充,如下所示显示如何按行填充
<tr *ngFor="let tablerows of data">
<td>
{{tablerows.row_id}}
</td>
<td>{{tablerows.number}}</td>
<td >{{tablerows.employee_name}}</td>
<td >{{tablerows.manager_name}}
</td>
</tr>
是否可以通过角度来做到这一点?或者也许我应该在组件中创建一些数组?
【问题讨论】:
-
你在用材料吗?
-
@programoholic 引导
-
你能发布行 json 的样本吗?
标签: angular html-table