Issue
I get the data like so:
getLeads(): Observable<LeadModel[]> {
return this.angularFireDatabase
.list<LeadModel>(`groups/${this.groupId}/leads`)
.valueChanges()
.pipe(map((res) => orderBy(res, ['createdDate'], ['desc'])));
}
.HTML
<ion-col>
<p>
{{ lead.createdDate | date: 'MMM dd' }}
<br />
{{ lead.createdDate | date: 'h:mm a' }}
</p>
</ion-col>
I use Lodash orderBy here.
I use DayJS for date formating like so when I saved the data to Firebase
createdDate: dayjs().format(),
But I cannot see the date
order by desc
here. Do you know why?
Solution
I have changed my model like so:
createdDate?: number;
Then used unix()
createdDate: dayjs().unix(),
After that:
getLeads(): Observable<LeadModel[]> {
return this.angularFireDatabase
.list<LeadModel>(`groups/${this.groupId}/leads`)
.valueChanges()
.pipe(map((res) => orderBy(res, ['createdDate'], ['desc'])));
}
All are working fine now.
Answered By - Sampath
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.