我试图使用ng-repeat创建一个表,但我无法弄清楚如何让它工作。我最好的尝试是下面的。
<table ng-repeat="j in [0,1,2,3,4,5,6,7]">
<tr>
<th>
Header {{j+1}}
</th>
</tr>
<tr ng-repeat="i in [0,1,2,3,4,5,6,7]">
<td>
{{i+1}} , {{j+1}}
</td>
</tr>
</table>
任何想法?
答案 0 :(得分:1)
首先,ng-repeat属性在表中,这意味着您重复此元素的次数与数组中的条目一样多。知道“tr”代表行,而“td”代表行中的不同部分。
你可以尝试:
<table>
<tr><!--this is your header row -->
<th>
Header {{j+1}}<!-- this is a header section, you can repeat here or use it as a title -->
</th>
</tr>
<tr ng-repeat="j in [0,1,2,3,4,5,6,7]"><!-- repeat the rows -->
<td ng-repeat="i in [0,1,2,3,4,5,6,7]"><!-- repeat the sections -->
{{i+1}} , {{j+1}}<!-- here you can display i, j whatever else -->
</td>
</tr>
</table>