Currently, I am utilizing a loop with for in
to iterate through a list of Meeting objects named allMeetings
. Inside this loop, I am populating another list called allEvents
, where non-Meeting objects will be stored. However, when attempting to access the properties of the Meeting object within the loop, they are not being recognized. I am seeking guidance on how to address or work around this issue.
Details about My Meeting model:
export class Meeting {
id: UUID;
date: Date;
description: string;
}
Concerning the TypeScript File:
The loop is implemented within the makeEvents()
method.
...
import { Meeting } from '../models/meeting.model';
import { MeetingsService } from '../services/meetings.service';
...
export class SomeComponent implements OnInit {
allEvents: SpikesEvent[] = undefined;
allMeetings: Meeting[] = undefined;
constructor(private _meetingsService: MeetingsService) { }
ngOnInit() {
this.loadMeetings();
this.makeEvents();
}
loadMeetings(): void {
this._meetingsService.getAllMeetings().subscribe(
(allMeetings: Meeting[]) => {
this.allMeetings = allMeetings;
}
);
}
makeEvents(): void {
for (let meeting in this.allMeetings) {
this.allEvents.push({
start: startOfDay(meeting.date),
title: meeting.description,
color: colors.yellowsunflower,
type: "meeting",
id: meeting.id,
});
}
}
}
Issues Faced: The properties like date, description, and id of a meeting object are not being recognized.
EDIT 1: Included the constructor in the TypeScript File.
EDIT 2: Just to clarify, I retrieve my data from rethinkDB so there's no JSON file involved. Nonetheless, here's a log entry to confirm that the Meeting object indeed contains data:
date: "Fri Feb 20 1993 00:00:00 GMT+00:00", description: "meeting about dummy data", id: "088c0baf-3c02-48b2-a072-65905fb0c0a7"