正在以以下格式从我的服务器检索数据
[{id: 1, title:"hello world", date:"2014-10-11",location: "The Room"},{id: 1, title:"hello world2", date:"2014-10-11",location: "The Room"}, {id: 1, title:"hello world3", date:"2014-10-11",location: "The Room"}]我试图在我的视图中像这样显示数据
我尝试在@Plantface的答案中使用下面的示例How can I group data with an Angular filter?,但是数据在我的视图中显示如下
日期似乎是重复什么时候is应该呈现一次。我是不是遗漏了什么?
发布于 2014-09-22 01:07:13
视点
<script type="text/ng-template" id="schedule.html">
<ion-view title="Schedule">
<ion-content>
<ion-list ng-repeat="date in datesToFilter() | filter:filterDates">
<div class="item item-divider">{{ date.date }}</div>
<ion-item href="#/tab/schedule/{{event.id}}" class="event item-icon-right" ng-repeat="event in events | filter:{date: date.date}">
<span class="time">{{ event.startstamp }}</span>
<span class="title">{{ event.title }}</span>
<i class="icon ion-chevron-right"></i>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
</script>主计长
function($rootScope, $scope, $q, API, $data, $window) {
$scope.events = $data.events;
var indexedDates = [];
$scope.datesToFilter = function() {
indexedDates = [];
return $scope.events;
}
$scope.filterDates = function(event) {
var isNew = indexedDates.indexOf(event.date) == -1;
if (isNew) {
indexedDates.push(event.date);
}
return isNew;
}https://stackoverflow.com/questions/25965000
复制相似问题