Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom comparator not working - ordering date #88

Closed
juliosardella opened this issue Sep 9, 2019 · 3 comments
Closed

Custom comparator not working - ordering date #88

juliosardella opened this issue Sep 9, 2019 · 3 comments

Comments

@juliosardella
Copy link

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
Copy link
Owner

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

@ragulmurugesan
Copy link

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

@juliosardella
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants