angular - ng 格式化表格
问题描述
我正在尝试在 Angular 中格式化表格。我有一个名字,姓氏,城市,国家的数据库。我正在尝试以表格格式显示数据。这是我的代码:
<table border="1" style="width:70%">
<tr bgcolor="lightblue">
<th style="width:20%">Last Name</th>
<th style="width:20%">First Name</th>
<th style="width:40%">Street</th>
<th style="width:20%">City</th>
</tr>
<tbody>
<span *ngFor="let i of x">
<tr>
<td>{{i.lastName}}</td>
<td>{{i.firstName}}</td>
<td>{{i.address.street}}</td>
<td>{{i.address.city}}</td>
</tr>
</span>
</tbody>
</table>
所有表格字段都显示在“姓氏”列下。
附上一张我的桌子的照片。
解决方案
删除span
,它不属于表格(单元格内除外)。将 ngFor 放入tr
代替。
推荐阅读
- javascript - jQuery 数据表重新加载
- vba - 如何通过 MS Access 在电子邮件中添加附件?
- bootstrap-4 - 如何修复百里香按钮?
- c# - 通过 rfc8141 匹配 URN 的正则表达式
- python-3.x - 在某个时间(日期)查找熊猫系列的一个元素
- amazon-web-services - 亚马逊 s3 存储桶的图片上传权限
- android - LiveData - 在第二次调用时未获取片段中的数据
- python - 根据熊猫中的索引范围组合列的行
- android - 来自android debuggerd的奇怪回溯
- angular - Core-js:找不到 object.keys 的模块