ng-repeat不使用表<tr>但与列表<li>一起使用

jsb*_*sht 2 javascript angularjs angularjs-ng-repeat

我有以下代码:Plnkr上的代码

我想ng-repeat在一张桌子里使用.但那不起作用.而相同的代码适用于列表<li>

这是一个相同的片段.

<h1>Using list</h1>
<ul>
  <li ng-repeat="item in sampleArray">{{item}}</li>
</ul>
<h1>Using Table</h1>
<table>
    <tr ng-repeat="item in sampleArray">{{item}}</tr>
</table>
Run Code Online (Sandbox Code Playgroud)

在其中使用ng-repeat是不正确的<tr>.我怎样才能正确使用表格.

Reb*_*nix 6

W3C HTML表定义

使用标记定义表.

表格分为带有标签的表格行.

表行分为带有标记的表数据.

表格行也可以分为带标签的表格标题.

所以根本原因是你错过了元素中的元素<td>或元素<th><tr>

<tr ng-repeat="item in sampleArray"><td>{{item}}</td></tr>
Run Code Online (Sandbox Code Playgroud)