wgo.js icon indicating copy to clipboard operation
wgo.js copied to clipboard

Board function fails in constructor

Open crodgers opened this issue 7 years ago • 2 comments

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)

crodgers avatar May 24 '17 18:05 crodgers

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.

waltheri avatar Jun 04 '17 14:06 waltheri

I'm planning to use wgo.js in an upcoming project. Is there a roadmap for the development of the 3.0.0 version?

pelevesque avatar Jun 05 '17 01:06 pelevesque