you are sorting the String, convert to Date object first :
//return piece
return function(records, from, to) {
var fromDate = new Date (from )
var toDate = new Date( to )
return records.filter(function(record) {
return new Date(record.Date) >= fromDate && new
Date(record.Date) <= toDate;
});
}
On Wednesday, February 3, 2016 at 3:57:04 PM UTC-7, Ali Jatoi wrote:
>
> var app = angular.module('app',[]).controller('ctrl1', function($scope){
>
> $scope.from = '05/02/2015';
> $scope.to = '05/04/2015';
>
> $scope.record = [
> {uniqueID : 'pp-12', Name : 'Jim', status : 'Approved',
> Date:'05/01/2015',eDate:'05/08/2015' },
> {uniqueID : 'pp-11', Name : 'Jim', status : 'Canceled',
> Date:'05/02/2015',eDate:'05/08/2015' },
> {uniqueID : 'pp-45', Name : 'Nick', status : 'Pending',
> Date:'05/03/2015',eDate:'05/08/2015' },
> {uniqueID : 'pp-32', Name : 'Thomas', status :
> 'Canceled', Date:'05/04/2015',eDate:'05/08/2015' },
> {uniqueID : 'pp-01', Name : 'Thomas', status : 'Pending',
> Date:'05/05/2015',eDate:'05/08/2015' },
> {uniqueID : 'pp-09', Name : 'Nick', status : 'Approved',
> Date:'05/06/2015',eDate:'05/08/2015' },
> {uniqueID : 'pp-23', Name : 'Lina', status : 'Requested',
> Date:'05/07/2015',eDate:'05/08/2015'},
> {uniqueID : 'pp-39', Name : 'Jim', status : 'Pending',
> Date:'05/08/2015',eDate:'05/08/2015' }
> ];
> })
>
> .filter('dateRange', function() {
> return function(records, from, to) {
> return records.filter(function(record) {
> return record.Date >= from && record.Date <= to;
> });
> }
> })
> when i do this data has been removed? *return record.Date >= from &&
> record.eDate <= to;*
> *i want to sort data between two dates? Help please*
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.