Trying to integrate scheduler to my Angular 2 project, getting this error when I try to init :
ERROR TypeError: Cannot read property '0' of undefined
at Object.<anonymous> (http://localhost:3000/14.chunk.js:441:208)
at Object.z [as ev_ontemplatesready] (http://localhost:3000/14.chunk.js:226:496)
at Object.obj.callEvent (http://localhost:3000/14.chunk.js:226:277)
at Object.webpackJsonpac__name_.974.scheduler.init_templates (http://localhost:3000/14.chunk.js:342:295)
at Object.webpackJsonpac__name_.974.scheduler.init (http://localhost:3000/14.chunk.js:270:472)
at http://localhost:3000/14.chunk.js:141:23
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.dll.js:4153:31)
at Object.onInvokeTask (http://localhost:3000/vendor.dll.js:5592:37)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.dll.js:4152:36)
at Zone.runTask (http://localhost:3000/polyfills.dll.js:3920:47)
at ZoneTask.invoke (http://localhost:3000/polyfills.dll.js:4215:38)
at timer (http://localhost:3000/polyfills.dll.js:5295:29)
at ____________________Elapsed_207_ms__At__Mon_May_22_2017_14_45_09_GMT_0200__Paris__Madrid__heure_d__t___ (http://localhost)
at getStacktraceWithUncaughtError (http://localhost:3000/polyfills.dll.js:3628:12) [angular]
at new LongStackTrace (http://localhost:3000/polyfills.dll.js:3622:22) [angular]
......
My init code :
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import "dhtmlx-scheduler";
import {} from "@types/dhtmlxscheduler";
import 'style-loader!../../../../node_modules/dhtmlx-scheduler/codebase/dhtmlxscheduler.css';
import 'style-loader!./calendar.scss';
@Component({
selector: 'scheduler',
templateUrl: './calendar.html',
styles: [
`
:host{
display: block;
height: 600px;
position: relative;
width: 100%;
}
`],
})
export class CalendarComponent implements OnInit {
@ViewChild("scheduler_here") schedulerContainer: ElementRef;
constructor() {}
ngOnInit() {
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.init(this.schedulerContainer.nativeElement, new Date(2010,0,6), "week");
}
}
In my template :
<div #scheduler_here style="width: 100%; height: 100%;"></div>
I try to init scheduler like I did for gantt (according to your tutorial) but it doesn’t work.