我无法在每行中显示数组previewSubs和preeviewGrades中的元素,如:
Subject Grade
Maths A
Maths B
Maths C
我尝试将ng-repeat属性放在元素上,但由于每个元素(tr)只能使用一个ng-repeat,我可以显示主题或成绩,但不能同时显示两者。
以下代码水平重复,我希望它像上表一样垂直向下重复。
<table>
<tr>
<th>Subject</th>
<th>Grade</th>
</tr>
<tr>
<td ng-repeat="psubs in previewSubs">{{psubs}}</td>
<td ng-repeat="pgrades in previewGrades">{{pgrades}}</td>
</tr>
</table>
答案 0 :(得分:0)
尝试:
<table>
<tr>
<th>Subject</th>
<th>Grade</th>
</tr>
<tr ng-repeat="psubs in previewSubs">
<td>{{ psubs }}</td>
<td>{{ previewGrades[$index] }}</td>
</tr>
</table>