Could anyone please explain to me what I'm doing wrong in the http get statement below? I'm trying to populate FullCalendar events dynamically, but no events are added. The service appears to be returning the same result as the "of". The runnable code is available here: https://stackblitz.com/edit/angular-ivy-1kat2n?file=src/app/app.component.ts
export class AppComponent implements OnInit {
events1 = [];
events2 = [];
calendarOptions1 = {
...
events: this.events1,
};
calendarOptions2 = {
...
events: this.events2,
};
constructor(public http: HttpClient) {}
ngOnInit() {
of([
{"title":"event 1","start":"1900-01-02T11:00:00","end":"1900-01-02T12:00:00"},
{"title":"event 2","start":"1900-01-02T11:00:00","end":"1900-01-02T12:00:00"}])
.subscribe((res) => {
Object.assign(this.events1, res);
}
);
this.http.get('https://mocki.io/v1/f7cdb3b1-5572-4503-9d61-a1671432d08b')
.subscribe(data => {
Object.assign(this.events2, data);
}
);
}
}
This is my HTML:
<full-calendar [options]="calendarOptions1"></full-calendar>
<full-calendar [options]="calendarOptions2"></full-calendar>