How to implement Fullcalendar in Angular 8?

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

Comments

35 responses to “How to implement Fullcalendar in Angular 8?”

  1. Julien Pitt Avatar
    Julien Pitt

    Thank you for this, it saved my lot of time

  2. Tanq Avatar
    Tanq

    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?

    1. Ajay Malhotra Avatar

      Yes this possible and I have that code also.

  3. Manikanta Avatar
    Manikanta

    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.

  4. Manoj Avatar
    Manoj

    How to refresh calendar?

  5. Yousra Benchelh Avatar
    Yousra Benchelh

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

    1. Ajay Malhotra Avatar

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

  6. Amol Mane Avatar
    Amol Mane

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

    1. Ajay Malhotra Avatar

      With title, you want to add show more link?

  7. Anthonyraj D Avatar
    Anthonyraj D

    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…

      1. Mike Avatar
        Mike

        I have the same issue, followed your youtube video.

  8. EagerAngularLearner Avatar
    EagerAngularLearner

    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

      1. EagerAngularLearner Avatar
        EagerAngularLearner

        Would this work for angular 8 too?

        1. Ajay Malhotra Avatar

          May be but Angular 9+ for sure.

  9. mohamed Avatar
    mohamed

    Manyyyyyyyy thanks my pro

  10. JuliaPeao Avatar
    JuliaPeao

    How to work video js with Angular 9?

    1. Ajay Malhotra Avatar

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

  11. JuliaPeao Avatar
    JuliaPeao

    Make video pls using video js

  12. rasool Avatar
    rasool

    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

    1. Ajay Malhotra Avatar

      Hi, I will update you on this.
      Thanks

  13. rasool Avatar
    rasool

    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 “.

    1. Ajay Malhotra Avatar

      You need to reinstall all. Thanks

  14. Ankita Dhabalia Avatar
    Ankita Dhabalia

    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.

      1. Ankita Dhabalia Avatar
        Ankita Dhabalia

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

  15. Sagar Avatar
    Sagar

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

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