ng-repeat 不适用于表 <tr>但适用于列表 <li> [英] ng-repeat not working with table <tr> but works with list <li>
问题描述
我有以下代码:Plnkr 上的代码
我正在尝试在表中使用 ng-repeat
.但这不起作用.而相同的代码适用于列表
I am trying to use ng-repeat
within a table. But that doesnt work. Whereas the same code works for list <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>
在 Is it incorrect to use ng-repeat within Per W3C HTML 表定义 表格是用标签定义的. 表格被分成带有标签的表格行. Tables are divided into table rows with the tag. 表格行通过标签划分为表格数据. Table rows are divided into table data with the tag. 表格行也可以用标签划分为表格标题. A table row can also be divided into table headings with the tag. 所以根本原因是您错过了 So the root cause is that you miss a 这篇关于ng-repeat 不适用于表 <tr>但适用于列表 <li>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 中使用 ng-repeat 是否不正确.我如何才能正确使用表.
<tr>
. How could i get the table usage right.推荐答案
元素中的 或 元素
<td>
or <th>
element inside your <tr>
element<tr ng-repeat="item in sampleArray"><td>{{item}}</td></tr>
登录
关闭