Javascript angularJS嵌套重复
我有以下格式的数据Javascript angularJS嵌套重复,javascript,html,angularjs,angularjs-ng-repeat,html-table,Javascript,Html,Angularjs,Angularjs Ng Repeat,Html Table,我有以下格式的数据 [ { "id": "1", "quizId": "2", "question": "What team is Messi playing ?", "quiz": [ { "id": "2", "categoryId": "67", "name": "Football Quiz", "quizsize": "0" } ], "answer
[
{
"id": "1",
"quizId": "2",
"question": "What team is Messi playing ?",
"quiz": [
{
"id": "2",
"categoryId": "67",
"name": "Football Quiz",
"quizsize": "0"
}
],
"answers": [
{
"id": "1",
"questionId": "1",
"name": "Barcelona",
"correct": "1"
},
{
"id": "2",
"questionId": "1",
"name": "M.City",
"correct": "0"
},
{
"id": "3",
"questionId": "1",
"name": "Real Madrid",
"correct": "0"
},
{
"id": "4",
"questionId": "1",
"name": "Liverpool",
"correct": "0"
}
]
}
]
我试图在一张桌子上展示它。
每个问题(根)都是一行,我得到quick.name,然后我尝试显示答案。name
<table class="table table-striped">
<tr>
<th>Title</th>
<th>Category</th>
<th>Answer 1</th>
<th>Answer 2</th>
<th>Answer 3</th>
<th>Answer 4</th>
</tr>
<tr ng-repeat="question in questions">
<td>{{ question.question}}</td>
<td>{{ question.quiz[0].name }}</td>
<td ng-repeat="answer in question.answers">
<td>{{ answer.name}}</td>
</td>
</tr>
</table>
标题
类别
答复1
答复2
答复3
答复4
{{问题.问题}
{{问题.测验[0].名称}
{{answer.name}
第二次ng重复没有显示任何内容。
我还尝试了回答[0]。名称。根据标准,您当前的HTML无效
td
元素不能嵌套,您应该使用不同的元素来显示td
内部的内容,如div
或span
标记
<tr ng-repeat="question in questions">
<td>{{ question.question}}</td>
<td>{{ question.quiz[0].name }}</td>
<td ng-repeat="answer in question.answers">
<div>{{ answer.name}}</div>
</td>
</tr>
{{问题.问题}
{{问题.测验[0].名称}
{{answer.name}
根据标准,您当前的HTML无效
td
元素不能嵌套,您应该使用不同的元素来显示td
内部的内容,如div
或span
标记
<tr ng-repeat="question in questions">
<td>{{ question.question}}</td>
<td>{{ question.quiz[0].name }}</td>
<td ng-repeat="answer in question.answers">
<div>{{ answer.name}}</div>
</td>
</tr>
{{问题.问题}
{{问题.测验[0].名称}
{{answer.name}
@Cristian很高兴帮助你..谢谢:)@Cristian很高兴帮助你..谢谢:)