I'm using a for in to loop over a list of Meeting-objects called allMeetings. This loop is filling another list called allEvents, where objects other than Meeting will end up in. In that loop I'm trying to get the properties of the Meeting object, but they aren't recognised. I wonder how to solve or bypass it.
My Meeting model:
export class Meeting {
id: UUID;
date: Date;
description: string;
}
The TS-File:
The loop is used in 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,
});
}
}
}
So, date, description and id of meeting aren't recognised.
EDIT 1: Added the constructor in the TS-File.
EDIT 2: I'm retrieving my data from rethinkDB so there's no JSON-file but here's a log to prove that the Meeting object is in fact not empty:
date: "Fri Feb 20 1993 00:00:00 GMT+00:00", description: "meeting about dummy data", id: "088c0baf-3c02-48b2-a072-65905fb0c0a7"
meetingisundefinedinsidemakeEventsmethod. Check the links to find out why.