I am trying to implement FullCalendar Scheduler in Angular 2, and I have followed the below specified steps -
Installed the required dependancy as below -
"dependencies": {
"fullcalendar": "^3.8.0",
"fullcalendar-scheduler": "^1.9.1",
"jquery": "^3.2.1",
"moment": "^2.20.1"
},
"devDependencies": {
"@types/jquery": "^2.0.47"
}
Updated the angular-cli.json
as below -
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/fullcalendar/dist/fullcalendar.min.css",
"../node_modules/fullcalendar-scheduler/dist/scheduler.min.css",
"../node_modules/primeng/resources/primeng.min.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"../node_modules/font-awesome/css/font-awesome.min.css"
],
"scripts": ["../node_modules/jquery/dist/jquery.js",
"../node_modules/moment/min/moment.min.js",
"../node_modules/fullcalendar/dist/fullcalendar.js",
"../node_modules/fullcalendar-scheduler/dist/scheduler.min.js"
],
I have imported the dependancies in main.ts
and module.ts
-
main.ts -
import * as jQuery from "jquery";
(window as any).$ = (window as any).jQuery = jQuery;
app.component.html -
<div id='calendar'></div>
app.component.ts
import { Component } from '@angular/core';
import 'fullcalendar';
import 'fullcalendar-scheduler';
declare let $: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
ngOnInit() {
$('#calendar').fullCalendar({});
}
}
I have solved the @type/jquery issue as specified in jQuery error anymore, however I am not able to compile the code it give below mentioned error -
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (347,6): Type 'string' is not assignable to type 'EmitterInterface[]'.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (124,27): ']' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (125,28): ']' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (125,33): ';' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (126,28): ']' expected.
ERROR in /Users/jeet/Documents/Development/frontend/node_modules/fullcalendar/dist/fullcalendar.d.ts (126,33): ';' expected.
Please find the full error here. I have already looked at below threads and resources and these doesn't seems to address the issue -
https://github.com/fullcalendar/fullcalendar/issues/3991 fullcalendar & Angular 5
I request your help regarding same.
This should work for you. Also you can have a look at the git repo too here https://gitlab.com/haque.mdmanzurul/ng-fullcalendar
app.component.ts
import * as jQuery from 'jquery';
(window as any).jQuery = (window as any).$ = jQuery; // This is needed to resolve issue.
import { Component, OnInit } from '@angular/core';
import 'fullcalendar';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'My Calendar';
ngOnInit() {
$('#calendar').fullCalendar({});
}
}
angular-cli.json:
"styles": [
"styles.css",
"../node_modules/fullcalendar/dist/fullcalendar.min.css"
],
"scripts": [
"../node_modules/fullcalendar/dist/fullcalendar.js"
],
package.json
{
"name": "mycalendar",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"core-js": "^2.4.1",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14",
"fullcalendar": "^3.4.0",
"jquery": "^3.2.1",
"moment": "^2.19.1"
},
"devDependencies": {
"@angular/cli": "1.4.9",
"@angular/compiler-cli": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/jquery": "^3.2.7",
"@types/node": "~6.0.60",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.3.3"
}
}