我正在尝试让内部ng-repeat工作。根据batarang,每个选择选择似乎都在DOM上生成,但在页面上不可见。不知道我做错了什么。任何指向正确方向的人都非常感激。
http://plnkr.co/edit/eoypUIYX07MpAvgT9wbT
<body ng-controller="qCtrl as quiz">
<div class="list-group">
<div class="list-group-item" ng-repeat="item in quiz.questions">
<h4>{{item.question}}</h4>
<div class="list-group-item" ng-repeat="selection in item.choices">
<h5>{{selection.choices}}</h5>
</div>
</div>
</div>
var app = angular.module('plunker', []);
app.controller('qCtrl', function() {
this.questions = allQuestions;
});
var allQuestions = [{
question: "Who is Prime Minister of the United Kingdom?",
choices: [
"David Cameron",
"Gordon Brown",
"Winston Churchill",
"Tony Blair"
],
correctAnswer: 0
}, {
question: "Who is the President of the United States of America? (2014)",
choices: [
"George Bush",
"Dan Quayle",
"Barack Obama",
"John F. Kennedy"
],
correctAnswer: 2
}];
答案 0 :(得分:3)
在.choices
之前删除selection
:
<h5>{{selection}}</h5>