Hi I'm trying to sort the dates in ascending order instead of decending. This is the code I that I have currently.
custome.pipe.ts
import {pipe, pipetransform} from '@angular/core';
import * moment from 'moment'
@pipe({
name: 'customDate'
})
export class customDatePipe implements pipeTransform{
transform(value: number | Date, formate?: string): string {
if(value){
const local = navigator.language;
if(!format){
format = 'L';
}
return moment(value, format, local).format(format);
}
return '-';
}
}
Cards.ts
@input() title: string;
@inpur() eventId: string;
@input() date: Date;
toString(date: Date){
return new Date(date?.toString()?.slice(0, -1))
}
card.html
<div {{toString(date) | customDate}}></div>
event-list.html
<app-cards
*ngFor="let event of projectEventList.projectsEvents"
(cardClick)="onClick($event, true);
[date]="getDate(event.eventDescription)"><app-cards>
event-list.ts
<privatr getProjectEvents(projectId: number){
this.projectEventSubscription = this.eventService.getProjectEvents(projectId).subscribe(events: PlukEvent[]) => {
event.sort(a:plukEvent, b:PlukEvent) =>(a.eventDate > b.eventDate ? 1 : b.event > a.eventDate ? -1 : 0))
this.projectEvents = events;
this.projectEventListSerive.setProjectEvent(events)
}
}