angular fullcalendar npm example. In this tutorial, you will learn step by step how to integrate or implement fullcalender in angular 11/12 app.
This tutorial guide will help you step by step onĀ angular 12 fullcalendar npm.
How to Integrate FullCalendar in Angular 12 App
Follow the following steps and integrate fullcalendar in angular 12 app:
- Step 1 ā Create New Angular App
- Step 2 ā Install FullCalendar Library
- Step 3 ā Add Code on App.Module.ts File
- Step 4 ā Add Code on View File
- Step 5 ā Add Code On app.Component ts File
- Step 6 ā Start theĀ Angular App
Step 1 ā Create New Angular App
First of all, open your terminal and execute the following command on it to install angular app:
ng new my-new-app
Step 2 ā Install FullCalendar Library
Then install NPM package called @fullcalendar/angular for implement fullcalendar in angular 11 app. So, You can install the packages by executing the following commands on the terminal:
npm install --save @fullcalendar/angular @fullcalendar/daygrid npm i @fullcalendar/interaction
Step 3 ā Add Code on App.Module.ts File
In this step, visit src/app directory and open app.module.ts file. And then add the following lines of into app.module.ts file:
...
import { FullCalendarModule } from '@fullcalendar/angular';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
FullCalendarModule.registerPlugins([
dayGridPlugin,
interactionPlugin
]);
...
imports: [
...
FullCalendarModule
],
...
Step 4 ā Add Code on View File
In this step, create fullcalendar in angular 11 app. So, visit src/app/ and app.component.html and update the following code into it:
<full-calendar [options]="calendarOptions"></full-calendar>
Step 5 ā Add Code On app.Component ts File
In this step, visit the src/app directory and open app.component.ts. Then add the following code into component.ts file:
...
import { CalendarOptions } from '@fullcalendar/angular'; // useful for typechecking
export class AppComponent {
...
calendarOptions: CalendarOptions = {
initialView: 'dayGridMonth',
dateClick: this.handleDateClick.bind(this), // bind is important!
events: [
{ title: 'event 1', date: '2020-06-27' },
{ title: 'event 2', date: '2020-06-30' }
]
};
handleDateClick(arg) {
alert('date click! ' + arg.dateStr)
}
}
Step 6 ā Start theĀ Angular App
In this step, execute the following command on terminal to start angular fullcalendar npm app:
ng serve