为什么我的ng-repeat不工作?

时间:2014-12-12 14:39:01

标签: javascript angularjs angularjs-ng-repeat hybrid-mobile-app

我很想做一个ng-repeat,它将检索卡片标题并将它们放入列表中。以下是我的代码中调用内容的部分:

<ion-content class="has-header" scroll="false" ng-controller="MainCtrl">
    <div id="accordian">
      <ul>
        <li>
          <h3><span class="icon-dashboard" ng-repeat="card in cards"></span>Group 1</h3>
          <ul>
            <li><a href="#">{{ card.title }}</a></li>
          </ul>
        </li>

这是控制器:

    .controller('MainCtrl', function($scope,$http) {

// Card Array
$scope.data = {};
$scope.cards =[
{checked: false, title:'Bank', src:'img/bank.png',details:'Description will go here!'},
{checked: false, title:'BBVA', src:'img/bbva.png',details:'Description will go here!'},
{checked: false, title:'Nike', src:'img/nike.png',details:'Description will go here!'},
];

1 个答案:

答案 0 :(得分:3)

您当前的代码会重复spancardcards的{​​{1}}标记。我不认为这是你打算做的。您可能想重复li,对吧?试试这个:

    <li ng-repeat="card in cards">
      <h3><span class="icon-dashboard"></span>Group 1</h3>
      <ul>
        <li><a href="#">{{ card.title }}</a></li>
      </ul>
    </li>