I am new to Angular. I have an array of events with multiple arguments. I want to filter them and have two new array files (upcoming events and past events). I have this code in typescript:
arrangeEvents(){
let datestring = this.eventList[this.index].date;
let dateObj = new Date(datestring);
let currentDateObj = new Date();
if(currentDateObj > dateObj){
upcomingEvents.push(this.eventList);
}else{
pastEvents.push(this.eventList);
}
}
This is the array file (this has multiple event values but this is just the first entry for reference:
export const events = [
{
eventShortName: 'IALC: How the Construction Industry Adapts to New Technologies?',
shortDesc: 'How Is Blockchain Driving Digital Transformation',
eventType: 'Webinar',
eventDetailsLink: ['/event-details', 'How-the-Construction-Industry-Adapts'],
paramLink: 'How-the-Construction-Industry-Adapts',
title: 'Industry Academe Linkage for Construction: How the Construction Industry Adapts to New Technologies?',
desc: 'This webinar will feature a panel discussion that revolves around the different technologies used in the construction industry in the Philippines and how CIORS could potentially be one of the new technologies to be used as a staple in the industry and academe.',
goal: 'The aim is to share knowledge with fellow members of the construction industry and construction academe on the various technologies used in the industry and how CIORS could play a role in it.',
date: '08/25/2021',
time:{
startTime: '11:30 AM',
endTime: '01:30 PM'
},
eventThumbnail: '../../../../assets/img/event1.png',
eventCover: '../../../../assets/img/event1.png',
registerLink: '#'
},
This is the html code:
<div *ngFor="let event of eventList">
<a [routerLink]="event.eventDetailsLink">
<div class="card border rounded shadow thumbnail"><img class="card-img-top w-100 d-block thumbnail-img" [src]="event.eventThumbnail" />
<div class="card-body">
<h6 class="card-title">{{ event.eventShortName }}</h6>
<div class="row g-0">
<div class="col-3 text-center">
<span class = "month">{{ getMonth(event.date) }}</span>
<br>
<span class ="date"><strong>{{ getDate(event.date) }}</strong></span>
<br>
<span class = "year">{{ getYear(event.date) }}</span>
</div>
<div class="col">
<h6 style="font-size: 14px;">{{ event.shortDesc }}</h6>
<p style="font-size: 10px;">{{ event.eventType }}</p>
</div>
</div>
</div>
</div>
</a>
</div>