嵌套的内部ng-repeat不显示文本,但更新$ scope

时间:2014-05-23 12:14:28

标签: angularjs

我正在尝试让内部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
}];

1 个答案:

答案 0 :(得分:3)

.choices之前删除selection

<h5>{{selection}}</h5>
相关问题