Reputation: 407
I am trying to use CreateJS in my Angular application. I have installed both the typing and createjs NPM packages. I have put /// <reference types="@types/createjs" />
at the top of my file. The app compiles, but in the web browser it gives me the error:
ERROR ReferenceError: createjs is not defined
How can I define 'createjs'? My typescript code is below. Thank you.
/// <reference types="@types/createjs" />
import { Component, AfterViewInit } from '@angular/core';
@Component({
selector: 'timeline-creator',
template: '<canvas width="1000" height="500"id="demoCanvas"></canvas>'
})
export class TimelineCreatorComponent implements AfterViewInit {
ngAfterViewInit (){
var stage = new createjs.Stage("demoCanvas")
var circle = new createjs.Shape();
circle.graphics.beginFill("DeepSkyBlue").drawCircle(0, 0, 50);
circle.x = 100;
circle.y = 100;
stage.addChild(circle);
stage.update();
}
}
Upvotes: 1
Views: 1523
Reputation: 9764
The @types for createjs seem to be formatted as a namespace instead of a module. If you import as below:
import 'createjs';
You can then access for example:
createjs.Stage
Upvotes: 1