Home > Software design >  Cannot order the date by desc on Lodash
Cannot order the date by desc on Lodash

Time:10-24

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 enter image description here

CodePudding user response:

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.

  • Related