简体   繁体   English

带有Angular 4的Ionic3中的FullCalendar

[英]FullCalendar in Ionic3 with Angular 4

How can I initialize fullCalendar in an event (for example, click) on Ionic 3, and with Angular 4? 如何在Ionic 3和Angular 4上的事件(例如,单击)中初始化fullCalendar?

This code work when set calendar options in variable: 在变量中设置日历选项时,此代码有效:

 calendarOptions: Object = {
    fixedWeekCount: true,
    editable: true
  };

But when I call into a function, don't work: 但是当我调用一个函数时,不起作用:

 buildCalendar(): void{
  this.calendarOptions: Object = {
    fixedWeekCount: true,
    editable: true
  };
 }

Html code where the calendar is called 日历称为的HTML代码

<angular2-fullcalendar 
          [options]="calendarOptions" 
          (initialized)="onCalendarInit($event)"></angular2-fullcalendar>

Angular code where buildCalendar is called: 调用buildCalendar的角度代码:

getAging(): void {

    this.myProvider.getAging()
      .subscribe(
      (response) => {
//do something...
      }, (error) => {
        console.log(`Backend returned code ${error.status}, body was: ${error.error}`);
      }, () => {
        console.log('aging complete');
        this.buildCalendar();
      }
      )

  }

PS: getAging() is called, on page load. PS:在页面加载时调用getAging()

And I need initialize fullCalender, after load data from backend (API). 从后端(API)加载数据后,我需要初始化fullCalender。

The issue is specific not to FullCalendar in general but to particular angular2-fullcalendar component and the way it works. 这个问题一般不是针对FullCalendar,而是针对特定的angular2-fullcalendar组件及其工作方式。

If it refers to this one , the problem is clear; 如果提到这一点 ,问题就很明显了。 it doesn't watch for options input and uses setTimeout hack to cover initial changes in the input (and 100 ms delay is unwanted here). 它不会监视options输入,而是使用setTimeout hack覆盖输入中的初始更改(此处不需要100 ms的延迟)。

Since the component is really simple, it's beneficial for the first party to implement it according to its needs instead of relying third-party solution. 由于该组件非常简单,因此第一方根据其需要而不是依赖第三方解决方案来实现它是有益的。

For this particular component ngIf should be used. 对于此特定组件,应使用ngIf It helps to prevent the component from being compiled until options are ready: 它有助于防止在选项准备就绪之前对组件进行编译:

<angular2-fullcalendar *ngIf="calendarOptions"
          [options]="calendarOptions" 
          (initialized)="onCalendarInit($event)"></angular2-fullcalendar>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM