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.