0

I'm using PrimeNG and I want to accomplish draggable events into a calendar in Angular, just like in the demo here. This is the live demo. The problem is that the example is in Vanilla JS and angular needs it on typescript.

I created a StackBlitz where I attempted to do so, but the calendar is simply not showing, because of the typescript code.

Alireza Ahmadi
  • 8,579
  • 5
  • 15
  • 42
nop
  • 4,711
  • 6
  • 32
  • 93

2 Answers2

2

First note that you forgot to add fullCalendar directive. Add below code to html:

<p-fullCalendar [events]="events" [options]="options"></p-fullCalendar>

Then in your option add editable:true.

Note that you can use ngModel to check the checkbox is checked or not but you need to add import { FormsModule } from '@angular/forms'; in your schedule.module. I fixed the issue and updated sample link.

Here is working sample.

But I think you also want to drag from other input to fullCalendar. So you need to implement draggable event in your service. This what you want to do second part

Alireza Ahmadi
  • 8,579
  • 5
  • 15
  • 42
1

As you are using primeng, you have to add calendar component from primeng like

  <p-fullCalendar [events]="events" [options]="options"></p-fullCalendar>

Now update your this.options to accept droppable event.

  droppable: true,

Also make your events as Draggable like below

let draggableEl = document.getElementById('external-events');

    new Draggable(draggableEl, {
      itemSelector: '.fc-event',
      eventData: function(eventEl) {
        return {
          title: eventEl.innerText
        };
      }
    });

Full Sample StackBlitz where I have modified your code

Yogen Darji
  • 3,230
  • 16
  • 31
  • Thank you! It works but once I put an item on the calendar, I'm not able to drag it from there back to the menu. Also "remove after drop" doesn't work as well. – nop Jul 05 '21 at 08:44