我正试图让内部的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
}];
将.choices
移到selection
之前:
<h5>{{selection}}</h5>