html - 如何在 html 和 Angular 中创建动态表
问题描述
我需要在 Html 中呈现一个动态表,我不知道每行的模板是什么:有时它包含 2 列,有时包含 4...
我需要这样的东西:
<div>
<h1>Angular HTML Table Example</h1>
<table>
<thead>
<tr>
<th>#ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of ItemsArray">
<th>{{ item.id }}</th>
<td>{{ item.name }}</td>
<td>{{ item.email }}</td>
<td>{{ item.phone}}</td>
<td>{{ item.address }}</td>
</tr>
</tbody>
</table>
</div
而不是:
<tr *ngFor="let item of ItemsArray">
<th>{{ item.id }}</th>
<td>{{ item.name }}</td>
<td>{{ item.email }}</td>
<td>{{ item.phone}}</td>
<td>{{ item.address }}</td></tr>
类似的东西:
<tr *ngFor="let item of ItemsArray">
<ngFor="let property of item.structure>
<td>{{ property }}</td>
你对我有什么建议吗?
谢谢
解决方案
推荐阅读
- excel - 尝试检索列标题时代码失败
- hyperledger-fabric - ENDORSEMENT_POLICY_FAILURE 遵循更新的 Build First Network 教程
- asynchronous - Promise.all 不会等到 .then()
- google-maps - 当我缩小时,svg 图标不会停留在折线上
- c# - 通过类在表单内共享数据
- javascript - 渲染模板时golang包含javascript文件
- r - 闪亮 - 无法显示条形图
- python - 使用 shell 或 python 将平面文件转换为不同的格式
- excel - IMEX=0 的 Excel ADODB 查询不从第一行返回数据
- linux - 保持打开的 linux 应用程序并注意崩溃