Search code examples
angular-clidhtmlx

DHTMLX Gantt Chart Usage with Angular 2 Framework gives an error


Did all step according to the tutorial given by DHTMLX. However getting error while init gantt:

import {Component, ElementRef, OnInit, ViewChild} from "@angular/core";
import "dhtmlx-gantt";


@Component({
    selector: "gantt",
    styles: [
        `
        :host{
            display: block;
            height: 600px;
            position: relative;
            width: 100%;
        }
    `],
    template: "<div #gantt_here style='width: 100%; height: 100%;'></div>",
})
export class GanttComponent implements OnInit {
    @ViewChild("gantt_here") ganttContainer: ElementRef;

    ngOnInit(){
        gantt.init(this.ganttContainer.nativeElement);
    }
}

Here is an error

ERROR in src/app/views/tasks/gantt.component.ts(19,3): error TS2304: Cannot find name 'gantt'.

I didn't find any difference between my and dowloaded project, which runs without any error. Link to git https://github.com/DHTMLX/angular2-gantt-demo


Solution

  • adding three lines of code in tsconfig.app.json file solves all problem

    "types": [
        "dhtmlxgantt"
    ]