1

I have a ng-repeat of items and I'm trying to filter the list with a date range using the Bootstrap UI datepickers. Im not entirely sure what the best approach is to do this.

I have two datepickers, dateFrom & dateTo and when selected I would like it to date range filter the items by CreatedOn as below:

<div ng-repeat="orderObj in filteredOrders = orders | filter: ({CreatedOn: dateFrom} || {CreatedOn: dateTo})" class="authorisation-row">

 <div class="c1">
    {{orderObj.OrderReference}}
</div>
 <div class="c2">
     {{orderObj.DeliveryAddress}}
 </div>
<div class="c3">
    {{orderObj.CreatedOn | date:'dd/MM/yyyy'}}
</div>

My controller code looks like this, I added a watcher to update the items by dateFrom but I'm not sure if this will work for both datepickers.

 $scope.orders = orderFactory.get({ id: selectUser });

$scope.orders.$promise.then(function () {

    $scope.$watch('dateFrom', function (newVal, oldVal) {
        $scope.filteredOrders = filterFilter($scope.orders, newVal);

    }, true);
});

I would be very grateful for any tips or advice to get this working.

Graeme Paul
  • 1,143
  • 1
  • 16
  • 30
  • 1
    http://stackoverflow.com/questions/25515431/ng-repeat-filtering-data-by-date-range – devqon Mar 24 '15 at 11:24
  • Thanks for the example, I would like show a list of items and be able to filter dates with the datepickers. The example you gave works differently – Graeme Paul Mar 24 '15 at 15:27

0 Answers0