Home Angular 8 How to implement Fullcalendar in Angular 8?

How to implement Fullcalendar in Angular 8?

by therichpost
Published: Last Updated on 35 comments
Angular 9, Angular 10

Hello to all, welcome to therichpost.com. In this post, I will tell you, How to implement Fullcalendar in Angular 8?

Today I am writing my first post related to Angular 8.

Important: FullCalendar has been update to version 5 So please check below link first:

Angular 8
fullcalendar


In this post, I will implement Fullcalndar in Angular 8 with the help of jQuery.

1. Let start, here are the basics commands to set Angular 8 into your pc:

$ npm install -g @angular/cli //Setup Angular8 atmosphere

$ ng new angularlatest8 //Install New Angular App

/**You need to update your Nodejs also for this verison**/

$ cd angularlatest8 //Go inside the Angular 8 Project

2. After Install Angular 8 fresh setup and go inside the Angular 8 setup, run below command into your terminal to install Fullcalendar and jQuery modules:

$ npm install jquery --save //Add jquery module

$ npm i fullcalendar //Add fullcalendar module

$ npm i moment //Add momentjs library

$ ng serve //Run your Angular 8 Project

Β Now you are few inches left to implement Fullcalendar in Angular8

3. Here is the code, you need to add into your angular.json file in root folder:

...
"styles": [
              "src/styles.css",
              "node_modules/fullcalendar/dist/fullcalendar.min.css"
            ],
            "scripts": ["node_modules/jquery/dist/jquery.min.js",
            "node_modules/moment/min/moment.min.js",
            "node_modules/fullcalendar/dist/fullcalendar.min.js"]
...

4. Here is the code, you need to add into your src/app/app.component.ts file:

import { Component } from '@angular/core';
declare var $: any;
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'easyfullcalendar';

ngOnInit(){
       setTimeout(() => {
        $("#calendar").fullCalendar({  
                        header: {
                            left   : 'prev,next today',
                            center : 'title',
                            right  : 'month,agendaWeek,agendaDay'
                        },
                        navLinks   : true,
                        editable   : true,
                        eventLimit : true,
                        events: [
                            {
                                title : 'This is your',
                                start : '2019-03-03T12:30:00',
                                color : '#f9c66a' // override!
                            },
                            {
                                title : 'Your meeting with john',
                                start : '2019-03-07T12:30:00',
                                end   : '2019-03-09',
                                color : "#019efb"
                            },
                            {
                                title  : 'This is Today',
                                start  : '2019-03-12T12:30:00',
                                allDay : false, // will make the time show,
                                color  : "#57cd5f"
                            }
                        ],  // request to load current events
                    });

     }, 100);
   }
}

5. Finally, here is the code for you src/app/app.component.html file:

<div id="calendar"></div>

You are done and if you have any query related to this post, then please do comment below or ask questions.

Jassa

Thank you

You may also like

35 comments

Julien Pitt October 29, 2019 - 7:57 am

Thank you for this, it saved my lot of time

Reply
Ajay Malhotra November 12, 2019 - 5:31 am

Great!!

Reply
Tanq December 18, 2019 - 2:02 am

Thanks, very useful! I will attempt to implement this soon but I was wondering if you know whether it is possible to add a custom button with a print event that will load the printer preview in landscape mode?

Reply
Ajay Malhotra December 18, 2019 - 4:06 pm

Yes this possible and I have that code also.

Reply
Manikanta February 7, 2020 - 6:48 am

How to bind data to the Full Calendar From WEB API. Could please share the code and how to add events and dispaly it on the screen.

Reply
Manoj April 27, 2020 - 5:56 pm

How to refresh calendar?

Reply
Yousra Benchelh May 19, 2020 - 8:54 pm

ERROR TypeError: $(…).fullCalendar is not a function
error

Reply
Ajay Malhotra May 20, 2020 - 2:51 am

Did you follow my tutorial completely? Did you ad jquery?

Reply
Amol Mane May 21, 2020 - 6:08 am

Hi Ajay can we show more details of event on calendar along with the title.

Reply
Ajay Malhotra May 21, 2020 - 6:15 am

With title, you want to add show more link?

Reply
Anthonyraj D July 2, 2020 - 12:56 pm

I got like this error when I run my application => “An unhandled exception occurred: Script file node_modules/fullcalendar/dist/fullcalendar.min.js does not exist.
See “/private/var/folders/75/_ls3ffvs0s5_xphp6j0sh0xh0000gp/T/ng-WjgCvo/angular-errors.log” for further details.”

What can I do…

Reply
Ajay Malhotra July 2, 2020 - 3:17 pm

Hi, Fullcalendar has been updated so please check this:
https://therichpost.com/how-to-implement-fullcalendar-in-angular-9-10/

Reply
Mike July 11, 2020 - 9:55 am

I have the same issue, followed your youtube video.

Reply
Ajay Malhotra July 11, 2020 - 9:57 am Reply
EagerAngularLearner July 11, 2020 - 9:58 am

Hi Ajay,

Do you know how to embedd a camera into an angular app?

So that the user accessing the website can for example either take a picture of themselves on the website or record themselves?

Many thanks,

Angular learner

Reply
EagerAngularLearner July 11, 2020 - 10:07 am

Would this work for angular 8 too?

Reply
Ajay Malhotra July 11, 2020 - 10:08 am

May be but Angular 9+ for sure.

Reply
mohamed July 23, 2020 - 11:48 pm

Manyyyyyyyy thanks my pro

Reply
Ajay Malhotra July 24, 2020 - 2:20 am

welcome bro

Reply
JuliaPeao August 7, 2020 - 8:58 am

How to work video js with Angular 9?

Reply
Ajay Malhotra August 7, 2020 - 9:00 am

You want to run video in angular app? or make video?

Reply
JuliaPeao August 7, 2020 - 11:23 am

Make video pls using video js

Reply
Ajay Malhotra August 19, 2020 - 6:11 am

Please check this link :
https://youtu.be/RU_blUIEM80

Reply
rasool August 13, 2020 - 8:59 am

how to add list week view in full calendar, i am not able to display list week in full calendar,

import listPlugin from ‘@fullcalendar/list’;
this.model = [];
const todayDate = new Date();
const todayDateStr = todayDate.getFullYear() + ‘-‘
+ (‘0’ + (todayDate.getMonth() + 1)).slice(-2) + ‘-‘
+ (‘0’ + (todayDate.getDate())).slice(-2);
this.fullcalendarOptions = {
plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin,listPlugin ],
defaultDate: todayDateStr,
header: {
left: ‘prev,next’,
center: ‘title’,
right: ‘dayGridMonth,listWeek’,
},
};

this is my code pls help me

Reply
Ajay Malhotra August 13, 2020 - 9:07 am

Hi, I will update you on this.
Thanks

Reply
Ajay Malhotra August 13, 2020 - 4:27 pm Reply
rasool August 19, 2020 - 6:07 am

but when i added listPlugin in my application I’m getting issue like this “Please import the top-level full calendar lib before attempting to import a plugin “.

Reply
Ajay Malhotra August 19, 2020 - 7:47 am

You need to reinstall all. Thanks

Reply
Ankita Dhabalia September 22, 2020 - 12:57 pm

Hi Ajay
I’m using angular 8 and getting the same issue. Followed all steps yet getting ERROR TypeError: $(…).fullCalendar is not a function
error.

Waiting for the possible solution.

Reply
Ankita Dhabalia September 23, 2020 - 9:39 am

Thanks Ajay yes I tried that post later on n it worked well.

Reply
Ajay Malhotra September 23, 2020 - 9:59 am

Great πŸ™‚

Reply
Sagar May 27, 2021 - 6:14 am

Hi Aj,

Can you please help me to set multiple span inside title?? like ,

events: [ {

title :”Spend:” + element.SpendAmount.toString() +”\nImp:” + element.Impressions.toString() +”\nClick:” + element.clicks.toString()+””,
start : β€˜2019-03-03T12:30:00’,
color : β€˜#f9c66a’

} ]
So I want one span for “spend”:value, 2nd span for “Imp”:values and 3rd span for “click”:values

Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.