VadimDez / ngx-order-pipe

▼ Angular 5+ orderBy pipe
https://vadimdez.github.io/ngx-order-pipe/
MIT License
243 stars 57 forks source link

Custom comparator not working - ordering date #88

Closed juliosardella closed 4 years ago

juliosardella commented 4 years ago

Hi, i can't use a custom comparator method. The values are going undefined:

html: <tr *ngFor="let user of users | orderBy: 'order':false:'case-insensitive':customComparator">

ts: customComparator(itemA, itemB) { console.log("itemA:" + itemA); console.log("itemB:" + itemB); return itemA > itemB ? 1 : -1; }

result in console (in loop): itemA:undefined itemB:undefined

I'm doing something wrong? My main objective is to order custom date field.

Thanks

VadimDez commented 4 years ago

Could you try it on stackblitz as well? https://stackblitz.com/edit/ngx-order-pipe?embed=1&file=app/app.component.ts

ragulmurugesan commented 4 years ago

@juliosardella I tried with your method. It is working fine. Can you post the 'users' object?

juliosardella commented 4 years ago

Hello my friends, i'm sorry for wasting your time. My problem was solved by changing the 'order' field from private to public. Thanks