所以我在这里找到了这个过滤器,这个过滤器没有$ watch。
filter.js
.filter('myfilter', function ($filter, moment) {
return function (items, from, to) {
return $filter('filter')(items, 'name', function (v) {
var date = moment(v);
return date >= moment(from) && date <= moment(to);
});
};
})
table.html
<table class="table table-bordered table-sm">
<thead class="">
<tr>
<th>DAY</th>
<th>TIME IN</th>
<th>TIME OUT</th>
<th>DETAILS</th>
<th>TOTAL HOURS</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="attendance in displayedCollection | myfilter: startDate: endDate">
<td>{{ attendance.day | date: 'EEEE, MMM d'}}</td>
<td>{{ attendance.timeIn | date:'h:mm a' }}</td>
<td>{{ attendance.timeOut | date:'h:mm a'}}</td>
<td class="text-capitalize">
<i class="fa fa-map-marker" aria-hidden="true"></i> {{ attendance.details }}</td>
<td>{{ attendance.totalHrs | date:'hh:mm'}} </td>
</tr>
</tbody>
<tfoot>
<tr>
<td>
<strong>Total</strong>
</td>
<td></td>
<td></td>
<td></td>
<td>
<strong>{{ vm.attendance.total }}</strong>
</td>
</tr>
</tfoot>
</table>
如何查看过滤器,因为displayedCollection.length
没有变化?