-1

I am trying to trigger an event when a user clicks on a resource:

enter image description here

I am wondering how I can do this in Angluar? I have seen posts for react but I am not sure if someone has managed to do it in Angluar?

ADyson
  • 57,178
  • 14
  • 51
  • 63
Ben Howard
  • 39
  • 4
  • Which version of fullCalendar are you actually using? Don't spam all the version tags please, because their APIs are different, so the answer to your question might be different. Also, are you using the fullCalendar-angular plugin provided by fullCalendar? – ADyson Nov 25 '21 at 11:05
  • Essentially though, fullCalendar's API is always available to you no matter which UI framework you're using, it's only that the syntax might differ slightly for setting up the options. But the documentation for each of the plugins (react, vue, angular) is available on the fullCalendar website and gives examples of the syntax for setting callback options, calling methods etc. So where exactly are you stuck? Have you tried anything? It would be useful if you shared your existing calendar setup code. – ADyson Nov 25 '21 at 11:07
  • Thanks for updating the tags. Can you provide clarification on the other points I've raised please too? Then I might be able to provide some useful, targeted assistance – ADyson Nov 25 '21 at 11:54

1 Answers1

2

If you are using FullCalnedar-5 https://fullcalendar.io/docs/resource-render-hooks

You can use resourceLabelDidMount like the following:

 public calendarOptions: CalendarOptions


  ngOnInit(): void {
    this.calendarOptions = {
      ...,// other features
      resourceLabelDidMount: this.resourceRender.bind(this)
    }
  }


  private resourceRender({ el , resource }) {
    console.log(resource)// more info about resource
    el.addEventListener("click", function () {
      // do what you want
    });
  }
Abolfazl Roshanzamir
  • 12,730
  • 5
  • 63
  • 79