Categories

Friday, November 22, 2024
#919814419350 therichposts@gmail.com
Angular 10Bootstrap 4.5MysqlPhp

Angular 10 FullCalendar Add Event Demo Part 1 with Source Code

Angular 10 FullCalendar Add Event Demo Part 1 with Source Code

Hello my friends, welcome back to my blog. Today in this blog post, I am going to tell you, Angular 10 FullCalendar Add Event Demo Part 1 with Source Code.

Angular 10 FullCalendar Add Event

Angular 10 came and if you are new then you must check below two links:

  1. Angular10 for beginners
  2. Angular10 Basic Tutorials

Friends now I proceed onwards and here is the working code snippet for Angular 10 FullCalendar Add Event Demo Part 1 with Source Code and please use carefully this to avoid the mistakes:

1. Firstly friends we need fresh angular 10 setup and for this we need to run below commands but if you already have angular 10 setup then you can avoid below commands. Secondly we should also have latest node version installed on our system:

npm install -g @angular/cli 

ng new angularaddevent //Create new Angular Project

cd angularaddevent // Go inside the Angular Project Folder

ng serve --open // Run and Open the Angular Project

http://localhost:4200/ // Working Angular Project Url

 

2. Now friends, here we need to run below commands into our project terminal to install fullcalendar modules, bootstrap(for good looks), jquery to support bootstrap  modules into our angular application:

npm install --save @fullcalendar/angular @fullcalendar/daygrid

npm i @fullcalendar/interaction

npm i bootstrap --save

npm i jquery --save

ng serve --o

 

3. Now friends, here we need to add below  into our angular.json file to get modules styles and scripts:

...
"styles": [
              ...
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              
              
            ],
            "scripts": [
              ...
              "node_modules/jquery/dist/jquery.min.js", 
              "node_modules/bootstrap/dist/js/bootstrap.min.js", 
              
              
            ]
...

 

4. Now add below code into your src/app/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 
  ],
 ...

 

5. Now add below code into your src/app/app.component.ts file:

...
declare let $: any;
import { CalendarOptions } from '@fullcalendar/angular';
export class AppComponent {
  ...
  calendarOptions: CalendarOptions;
  ngOnInit() {
    this.calendarOptions = {
      initialView: 'dayGridMonth',
      dateClick: this.handleDateClick.bind(this),
    events: [
      { title: 'event 1', date: '2020-11-05' },
      { title: 'event 2', date: '2020-06-30' }
    ]
  };
}
handleDateClick(arg) {
  $("#myModal").modal("show");
  $(".modal-title").text("");
  $(".modal-title").text("Add Event at : "+arg.dateStr);

    
}
}

 

6. Finally add below code into your src/app/app.component.html file:

<div class="container" style="margin-top:30px">
  <div class="row">
    <div class="col-sm-12">
      <full-calendar [options]="calendarOptions"></full-calendar>

    </div>
  </div>
</div>



<!--Modal-->
<div class="modal" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
    
      <div class="modal-header">
        <h4 class="modal-title align-center"></h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      
      <div class="modal-body text-center">
      </div>
    </div>
  </div>
</div>

 

Now we are done friends and please run ng serve command and if you have any kind of query then please do comment below.

Guys, in my next post, I will show you add event form in bootstrap modal popup.

Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.

I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

Jassa

Thanks

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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