【发布时间】:2017-07-03 17:35:46
【问题描述】:
API 连接良好并显示显示数据,现在面临将数据格式化为表格的问题。 使用 ng-repeat="item in items", 如果在 tr 中使用,则只显示 1 行,如果在 tbody 中使用,则重复 tbody。
HTML 代码
<tbody ng-repeat="item in itemsc">
<tr >
<th width="15%">Country</th>
<td width="85%">{{item.name}}</td>
</tr>
<tr>
<th>Flag</th>
<td>
<img ng-src="/assets/images/f/{{item.iso2 | lowercase}}.png" />
</td>
</tr>
<tr>
<th>Capital</th>
<td>{{item.capital}}</td>
</tr>
<tr>
<th>Region</th>
<td>{{item.region}}</td>
</tr>
<tr>
<th>Region</th>
<td>{{item.subRegion}}</td>
</tr>
<tr>
<th>GPS</th>
<td>Latitude: {{item.latitude}} | Longitude: {{item.longitude}}</td>
</tr>
</tbody>
保持这样的数据格式。 国家、国旗、首都、地区、GPS 是静态的。
> -------------------------------
| Country | Value |
> -------------------------------
| Flag | Value |
> -------------------------------
| Catpital | Value |
> -------------------------------
| Region | Value |
> -------------------------------
| GPS | Value |
> -------------------------------
【问题讨论】:
-
将
ng-repeat放在table上
标签: angularjs