ng-repeat不适用于表< tr>但适用于列表< li> [英] ng-repeat not working with table <tr> but works with list <li>

查看:104
本文介绍了ng-repeat不适用于表< tr>但适用于列表< li>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我正在尝试在表中使用ng-repeat.但这不起作用.而相同的代码适用于列表<li>

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>

<tr>中使用ng-repeat是否不正确.我该如何正确使用桌子.

Is it incorrect to use ng-repeat within <tr>. How could i get the table usage right.

推荐答案

每个 W3C HTML表定义

表是用标记定义的.

Tables are defined with the tag.

表通过标记分为多个表行.

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.

所以根本原因是您错过了<tr>元素内的<td><th>元素

So the root cause is that you miss a <td> or <th> element inside your <tr> element

<tr ng-repeat="item in sampleArray"><td>{{item}}</td></tr>

这篇关于ng-repeat不适用于表&lt; tr&gt;但适用于列表&lt; li&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆