我知道如何使用ng-repeat
創建可變數量的表格單元格,但是如何對錶格行執行此操作?我試圖創建一個危險的風格遊戲,其中表格行的數量應該等於每列中的問題數量。這裏是我的JSON是如何構成的:ng重複錶行的可變數量
app.js
$scope.subjects = [
{topic:'politics',question:['How do we fix our bloated economy?'],answer:'We trim the Fiat'}
//more questions & topics
]
問題應加列,他們應該按主題。我不能右腳下去;在下面的代碼中,我嘗試創建與問題數組長度相等的錶行數,但它不起作用。
view5.html
<table>
<tr ng-repeat='i in subjects[0].question'>
<!-- <td ng-repeat='subject.question[i] in subjects'></td> should get question for the corresponding topic -->
</tr>
</table>