Angular manages Fullcalendar, causing ViewRender to activate

I'm having trouble triggering an event when the view changes in Fullcalendar. Specifically, I need to detect when the month shifts to the previous or next one. I tried using ViewRender, but it didn't work for me. I've come across several resources suggesting that ViewRender is the solution, but I couldn't find any Angular implementation of it. This makes me doubt if my approach is correct. Additionally, passing view and element parameters to the function didn't yield any results either.

Here's my function:

eventViewRender() {
  console.log("Working here");
}

This is my HTML markup:

<full-calendar
      defaultView="dayGridMonth"
      [weekends]="options.calendarWeekends"
      [events]="eventsModel"
      (select)="multiSelected($event)"
      (eventDrop)="eventDragStop($event)"
      [plugins]="options.plugins"
      (viewRender)="eventViewRender()"
></full-calendar>

Answer №1

This example showcases my custom calendar component where the functionality for fetching new events is controlled by an @Input that references a function. I acknowledge that there may be more elegant solutions available and welcome feedback from those with greater expertise on how to enhance it.

 export class CalendarComponent implements OnInit, OnChanges {
  @Input() id: string
  @Input() ariaLabel: string
  @Input() height: string
  @Input() locale: string
  @Input() tabIndex: number
  @Input() callBack: (e, s, f) => {} = (e, s, f) => []
  @Input() view: 'timeGridWeek' | 'dayGridMonth' | 'dayGridWeek'
  @Input() events: QuixCalendarEvent[] = []
  @Input() header: { [key: string]: any }
  @Input() footer: { [key: string]: any }
  @Input() buttonsIcons: { [key: string]: any } = {
    close: 'fas fa-times',
    prev: 'fas fa-chevron-left',
    next: 'fas fa-chevron-right',
    prevYear: 'fas fa-angle-double-left',
    nextYear: 'fas fa-angle-double-right'
  }
  @Output() onEventClick = new EventEmitter<any>()
  @Output() onDateClick = new EventEmitter<any>()
  @Output() onViewChange = new EventEmitter<any>()
  calendarOptions: CalendarOptions = {
    initialView: this.view,
    themeSystem: 'bootstrap',
    events: this.viewChange.bind(this),
    height: '',
    eventClick: this.eventClick.bind(this),
    dateClick: this.dateClick.bind(this),
    headerToolbar: this.header,
    footerToolbar: this.footer,
    buttonIcons: this.buttonsIcons,
    locale: '',
  };

  constructor() {
  }

  ngOnInit(): void {
  }

  ngOnChanges(changes: SimpleChanges
  ) {
    if (changes.height?.currentValue) {
      this.calendarOptions.height = changes.height.currentValue
    }
    if (changes.view?.currentValue) {
      this.calendarOptions.initialView = changes.view?.currentValue
    }
    if (changes.header?.currentValue) {
      this.calendarOptions.headerToolbar = changes.header?.currentValue
    }
    if (changes.footer?.currentValue) {
      this.calendarOptions.footerToolbar = changes.footer?.currentValue
    }
    if (changes.locale?.currentValue) {
      this.calendarOptions.locale = changes.locale?.currentValue
    }
  }

  eventClick(event: any) {
    this.onEventClick.emit(event)
  }

  dateClick(event: any) {
    this.onDateClick.emit(event)
  }

  viewChange(event: any, successCallback, failureCallback) {
    this.onViewChange.emit(event)
    this.callBack(event, successCallback, failureCallback)
  }

}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Angular 6 and JavaScript to invoke two functions within an (ngClick) event in both the Component and JavaScript

I have a requirement to execute two functions in my click event, one for my component and the other for a custom JavaScript function. Here is the code snippet: Angular click event: <button type="button" class="btn btn-primary" (click)="Plans(); " [att ...

Unable to use global modules in NestJS without importing them

Currently, I am in the process of integrating a global module into my nest.js project I have written a service as shown below: export interface ConfigData { DB_NAME: string; } @Injectable() export class ConfigManager { private static _inst ...

Tips on how to access the previous and current state within a selector in ngrx selectors

I am interested in whether it is possible to access both the previous and current state within ngrx selectors. I have not been able to find relevant information on this topic. Could it be because I am using createSelector? Is there a factory method that ca ...

The error message indicated that a Promise<string> was expected, but instead a Promise<string|number> was received

Confusion Over Promise Type Error How did the TypeScript compiler generate the error message displaying Type Promise <string|number> ... in the following scenario? Type 'Promise<string | number>' is not assignable to type 'Prom ...

"Even after firing the observable through an event, the Async pipe continues to return null

I am currently working with an angular component that incorporates a rich text editor (tiptap v2) and displays the corresponding JSON output. I have created an observable from the update event provided by the editor, aiming to initialize the editor with mo ...

Having difficulty accessing the 'makeCurrent' property of an undefined object in Angular mobile application

I have followed the steps outlined in the Angular mobile toolkit guide found at https://github.com/angular/mobile-toolkit/blob/master/guides/cli-setup.md My Node version is v4.4.3 NPM version is 2.15.1 The issue arises when I run the command $ ng serve, ...

Encountering a compilation error when attempting to run ng serve in Angular, resulting in a failed build and

I am a beginner in using Angular and I recently downloaded a git repository. When trying to run the application, I encountered an error as shown below. If anyone can provide assistance, it would be greatly appreciated. Thank you in advance. I have attempt ...

Technique in CSS/SASS to repair a div

Seeking a solution for fixing divs with text in CSS. I am aware of the background-attachment: fixed; property which creates a fancy effect. Is there a similar property to "fix" divs with text or how can this be achieved in Typescript? Your insight would be ...

Angular: Implement a method from a designated service as a useFactory provider within a module

One of the challenges I am facing in my Angular5 application is related to a module that I am using in the following way: import *.... @NgModule({ providers: [ AuthentificationService, { provide: AuthHttp, useFactory: Authentificati ...

Using Owl Carousel 2 and other jQuery plugins in Angular 4 TypeScript classes: A step-by-step guide

I have been facing challenges trying to incorporate jQuery plugins into an Angular 4 TypeScript class. Despite multiple attempts, I have not been able to achieve my goal. I tried various methods, but the HTML component view in Angular 4 does not seem to s ...

React - Issue with updating DOM through method execution

I recently attempted to create a minesweeper game using TypeScript, but I've hit a roadblock. The issue I'm facing is that my renderBody() function doesn't seem to update the DOM when I change the boardState. Could someone please shed some ...

Challenges arise when the $_POST method fails to return a defined index

Although there are similar questions, none have fully addressed my issue. The challenge is to send values via POST to the DB to check if a user exists. Despite using isset and a ternary operator to handle errors, I still encounter persistent PHP errors. I ...

The Fixed Navbar is causing sections to be slightly off from their intended positions

Utilizing a bootstrap navigation menu on my website with a fixed position. When clicking a menu item, it takes me to the designated section but slightly above the desired position. How can I ensure that it goes to the exact position upon clicking the men ...

Unable to load HomeComponent in Angular 4 due to an error

Currently working on creating an app using the "An API of Ice and Fire". Encountering an issue with a displayed error message "ERROR Error: "[object Object]"" when attempting to redirect to homeComponent. Attached are screenshots displaying the error: B ...

Ways to integrate user input into the header of an Angular HTTP post method

I need help figuring out how to incorporate user input into the header of a post method I am working with. I understand that some kind of binding is necessary, but I'm struggling to implement it in this case. Currently, I have a variable called postDa ...

Using GULP and NODE, what is the best way to retrieve the Jenkins BUILD_NUMBER in JavaScript?

I am having an issue with my gulp task named getBuildNumber. This task utilizes the Child Process module to run a script. gulp.task('getBuildNumber', function() { var buildNumber = child_process.execSync("echo $BUILD_NUMBER").toString(). ...

Navigating with Angular 2 and configuring the .htaccess file

I've been experiencing some issues with my routing. Everything seems to be working fine on localhost, but when I upload it to the server and refresh the page, I keep getting a 404 Error. To address this problem, I created an .htaccess file and placed ...

The array contains data, yet the console is displaying a length of 0 for the array

I’m experiencing an issue with my code that involves a files array. Whenever I add a new file, it displays the incorrect length of the array. Strangely, if I use setTimeout to check the length, it shows the correct one. console.log('row.myDocuments ...

What is the best way to showcase the Observable information I receive from calling my api with Angular?

Just beginning my journey with Angular, I am on a quest to create a simple app that showcases a catalog of products. In my TypeScript file, I have a getProducts() function that calls an API and returns an observable list of products consisting of attribute ...

Why is my jQuery animate function with arrow function not working?

I am facing an issue with my animate method using an arrow function within an Angular class. The method does not seem to be executing properly when utilizing the this.innerWidth property to obtain the device width. Any assistance would be greatly appreci ...