过滤器不使用ion-list

时间:2015-06-24 22:01:07

标签: angularjs ionic-framework

我有一个包含三个分隔符的列表(今天,本周,之后),我想填充一些事件。我使用过滤器为每个分隔符排序每个事件,但我无法使其正常工作。它不会过滤任何东西。有帮助吗?我做错了吗?

这是我的HTML:

<ion-view view-title="Évènements à venir">
  <ion-content has-bouncing="false" has-tabs ="true" has-header="true">
    <ion-list>
     <div class="item item-calm item-divider">
    Aujourd'hui ()
  </div>
    <ion-item class="item item-avatar item-icon-right" ng-click="detail()" ng-repeat="soiree in test | filter:filterDay" type="item-text-wrap" >
        <img src={{}}>
        <h2>{{soiree.name}}</h2>
        <p>{{soiree.description}}</p>
        <i class="button icon ion-ios-checkmark-outline"></i>
        <ion-option-button class="button-assertive"
                       ng-click="removeSoiree(soiree)">
      Supprimer
    </ion-option-button>
    </ion-item>
     <div class="item item-calm item-divider">
    Cette semaine ({{soireeWeekNumber}})
  </div>
  <ion-item class="item item-avatar item-icon-right" ng-repeat="soiree in test | filter:filterWeek" type="item-text-wrap">
        <img src={{}}>
        <h2>{{soiree.name}}</h2>
        <p>{{soiree.description}}</p>
        <i class="button icon ion-ios-checkmark-outline"></i>
    </ion-item>
    </ion-list>
  </ion-content>
</ion-view>

这是我的过滤器和我的控制器:

.filter('filterDay', function() {
  return function(item) {
    var currentDate = new Date();
    if (Math.abs(currentDate - item.date) <= 1000*60*60*24) return true
    else return false
    }
})

.filter('filterWeek', function() {
  return function(item) {
    var currentDate = new Date();
    if (Math.abs(currentDate - item.date) > 1000*60*60*24 && Math.abs(item.date - currentDate) <= 7*1000*60*60*24) {
     return true
    } else {
     return false
    }}
})

.filter('filterFurther', function() {
  return function(item) {
    var currentDate = new Date();
    if (Math.abs(item.date - currentDate) >= 7*1000*60*60*24) {
     return true
    } else {
     return false
    }}
})

.controller('EventsCtrl', function($scope, $state, $ionicLoading, Soirees) {

  $scope.soirees = Soirees.all();
  $scope.test = [{papa: 1,date: new Date()},
  {papa: 2,date: new Date()},
  {papa: 3,date: new Date()}]

  $scope.detail = function() {
    $state.go('tab.detail')
  }
})

0 个答案:

没有答案