wgo.js
wgo.js copied to clipboard
Board function fails in constructor
I am trying to use the wgo npm module in Angular.
typings.d.ts:
declare module WGo {
export default function WGo();
}
in a directive:
import { Directive, ElementRef, Input, OnInit } from '@angular/core';
import WGo from "wgo";
@Directive({
selector: '[appGoBoard]'
})
export class GoBoardDirective implements OnInit {
@Input("appGoBoard") sgfData: string;
elem: ElementRef;
constructor(el: ElementRef) {
this.elem = el;
}
ngOnInit() {
let board = WGo.Board(
this.elem.nativeElement, {
width: 200
}
);
}
}
This code produces a js error in the browser:
ERROR TypeError: this.init is not a function
at Object.Board (Board.js:55)
at GoBoardDirective.webpackJsonp.204.GoBoardDirective.ngOnInit (go-board.directive.ts:16)
at checkAndUpdateDirectiveInline (core.es5.js:10705)
at checkAndUpdateNodeInline (core.es5.js:12084)
at checkAndUpdateNode (core.es5.js:12052)
at debugCheckAndUpdateNode (core.es5.js:12681)
at debugCheckDirectivesFn (core.es5.js:12622)
at Object.View_SnippetsListComponent_1.currVal_0 [as updateDirectives] (SnippetsListComponent.html:10)
at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:12607)
at checkAndUpdateView (core.es5.js:12019)
There are two problems - NPM module is not working for now (I have feeling it contains development version). Second WGo.Board
is constructor, should be created with new
.
I'm planning to use wgo.js in an upcoming project. Is there a roadmap for the development of the 3.0.0 version?