I'm facing a challenge where I need to iterate through an .subscribe() method placed inside an ngOnInit() method:
ngOnInit() {
this.service.getEmployees().subscribe(
(listBooks) => {
this.books = listBooks
var events: CalendarEvent[] = [
{
start: new Date(this.books[0].date_from_og), //loop instead of 0
end: new Date(this.books[0].date_to_og),
title: "" + this.books[0].device + "",
color: colors.yellow,
actions: this.actions,
resizable: {
beforeStart: true,
afterEnd: true
},
draggable: true
}];
this.events = events;
},
(err) => console.log(err)
);
}
I am trying to figure out how to loop through the books[ ] Array and populate every item into the events[ ] Array without any success so far.