File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-core-lib/src/lib/pipes/order-by-date.pipe.ts

Metadata

Name orderByDate

Methods

transform
transform(array: any[], field: string)
Parameters :
Name Type Optional
array any[] No
field string No
Returns : any[]
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'orderByDate'
})
export class OrderByDatePipe implements PipeTransform {

  transform(array: any[], field: string): any[] {
    return array.sort(function(a, b) {
        a = new Date(a[field]);
        b = new Date(b[field]);
        return a > b ? -1 : a < b ? 1 : 0;
    });
  }
}

result-matching ""

    No results matching ""