Angular-安装库fullcalendar时出错

时间:2018-08-05 23:07:54

标签: angular compiler-errors fullcalendar angular6 angular-module

我尝试按照以下步骤安装此日历库(https://www.npmjs.com/package/angular2-fullcalendar),但出现以下错误:

client.mute(call.callId).then(() => {
  console.log('Unmuted');
}).catch(err => {
  console.error('Failed to mute. ', err);
}); 

Chrome控制台给我以下错误:

ERROR in node_modules/angular2-fullcalendar/node_modules/@angular/core/src/facade/async.d.ts(8,10): error TS2305: Module '"<...>/node_modules/rxjs/Subject"' has no exported member 'Subject'.
node_modules/angular2-fullcalendar/node_modules/@angular/core/src/facade/async.d.ts(9,10): error TS2305: Module '"<...>/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/angular2-fullcalendar/node_modules/@angular/core/src/facade/async.d.ts(10,10): error TS2305: Module '"<...>/node_modules/rxjs/Subject"' has no exported member 'Subject'.
node_modules/angular2-fullcalendar/node_modules/@angular/core/src/util/lang.d.ts(8,10): error TS2305: Module '"<...>/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
node_modules/rxjs/Subject.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subject'.

我遵循了以下步骤:通过npm安装它,在我的app.module.ts中导入CalendarComponent,并在我的声明中@NgModule下对其进行声明。

然后我创建了一个名为home.component.ts的组件,并按照说明将以下内容复制到其中。

Uncaught Error: Can't construct a query for the property "myCalendar" of "HomeComponent" since the query selector wasn't defined.

我在以下位置添加了该选择器:

import { Component, OnInit } from '@angular/core';
import { PageEvent } from '@angular/material';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
  // MatPaginator Inputs
  length = 100;
  pageSize = 10;
  pageSizeOptions: number[] = [5, 10, 25, 100];

  // MatPaginator Output
  pageEvent: PageEvent;

  constructor() { }

  ngOnInit() {
  }

  setPageSizeOptions(setPageSizeOptionsInput: string) {
    this.pageSizeOptions = setPageSizeOptionsInput.split(',').map(str => +str);
  }

  calendarOptions:Object = {
    height: 'parent',
    fixedWeekCount : false,
    defaultDate: '2016-09-12',
    editable: true,
    eventLimit: true, // allow "more" link when too many events
    events: [
      {
        title: 'All Day Event',
        start: '2016-09-01'
      },
      {
        title: 'Long Event',
        start: '2016-09-07',
        end: '2016-09-10'
      },
      {
        id: 999,
        title: 'Repeating Event',
        start: '2016-09-09T16:00:00'
      },
      {
        id: 999,
        title: 'Repeating Event',
        start: '2016-09-16T16:00:00'
      },
      {
        title: 'Conference',
        start: '2016-09-11',
        end: '2016-09-13'
      },
      {
        title: 'Meeting',
        start: '2016-09-12T10:30:00',
        end: '2016-09-12T12:30:00'
      },
      {
        title: 'Lunch',
        start: '2016-09-12T12:00:00'
      },
      {
        title: 'Meeting',
        start: '2016-09-12T14:30:00'
      },
      {
        title: 'Happy Hour',
        start: '2016-09-12T17:30:00'
      },
      {
        title: 'Dinner',
        start: '2016-09-12T20:00:00'
      },
      {
        title: 'Birthday Party',
        start: '2016-09-13T07:00:00'
      },
      {
        title: 'Click for Google',
        url: 'http://google.com/',
        start: '2016-09-28'
      }
    ]
  };
}

以我的主要样式导入此文件。css:

<angular2-fullcalendar [options]="calendarOptions"></angular2-fullcalendar>

我将日历添加为子视图。

我的angular.json具有以下内容:

@import "fullcalendar/dist/fullcalendar.min.css";

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

这是因为Angular 6正在使用RxJS v6 。您尝试使用的日历包已经过时,并且正在使用目录不同的RxJS的较旧版本。 您可以做的是在产品目录中尝试npm install rxjs@6 rxjs-compat@6 --save,这基本上将为尚未更新为RxJS v6 的依赖项安装一个兼容性层。
希望对您有所帮助。
More Info


就您评论中的错误而言,这就是我安装/使用此软件包的方式。
在项目目录中:

npm i ap-angular2-fullcalendar jquery --save

要结合使用jquery和fullcalendar,您需要输入以下内容:

npm i --save-dev @types/jquery@3.2.7

将jquery和日历组件导入到应用模块。声明日历组件。

import * as $ from 'jquery'
import {CalendarComponent} from "ap-angular2-fullcalendar/src/calendar/calendar";

...

declarations: [CalendarComponent],

对于其他情况,我只使用了您提供的代码-仅更改了这一行:

calendarOptions:Object = {
    height: '600px',
    ...
}


Source