我想做一个 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 :
.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!'},
];
最佳答案
您当前的代码将为 cards
内的每个 card
重复 span
标记。我不认为那是你打算做的。您可能想重复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>
关于javascript - 为什么我的 ng-repeat 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27445954/