Adding Events to the Calendar
Let's add the functionality to display saved events on the calendar.
We'll cover the following...
At the moment, there’s a calendar within our dashboard, but there are no events under any of the week days.
Below is our updated code. Use this to make further changes.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>LetsGetLunch</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> </head> <body> <app-root></app-root> </body> </html>
Add calendar event properties
If you’re not sure if there are any events for your user, simply add a console.log() to the response within ngOnInit.
If the console within your browser shows null, create an event, because we’ll need one for display purposes.
At the moment, a sample response from getUserEvents might look like this.
We need it to look like this.
Our startTime and endTime, which are dates in ISO format, must be converted to JavaScript dates. More importantly, they must be set to the start and end properties. We also need to add a color property to the object, because the library requires this as well.
Once again, this isn’t exactly intuitive. This is a part of using ...