1

I'm using it with angular (ngx-blockly) and I want to create custom blocks like moveforward and so on ,so I followed all the steps in the tutorial ngx-blockly but I keep getting error about the type of the block and I didn't find information about the blocks type, is theres specific types when creating your own blocks , like in this tutorial the error was about "test"

here is the error enter image description here and here is my custom block code

 import { CustomBlock, NgxBlocklyComponent } from 'ngx-blockly';
 import { ViewChild } from '@angular/core';

 declare var Blockly: any;

 export class TestBlock extends CustomBlock {
 constructor() {
 super('TestBlock');
 this.class = TestBlock;
  }

defineBlock() {
this.block
  .appendDummyInput()
  .appendField(this.type)
this.block.setOutput(true, 'Input');
this.block.setColour(30);
this.block.setTooltip('');
this.block.setHelpUrl('');
}

toXML() {
return '<block type="test"></block>';
}
onChange(changeEvent: any) {
console.log(changeEvent);
}
 toDartCode(block: CustomBlock): string | any[] {
 return 'Not implemented';
 }

 toJavaScriptCode(block: CustomBlock): string | any[] {
 return 'Not implemented';
 }

 toLuaCode(block: CustomBlock): string | any[] {
 return 'Not implemented';
 }

toPHPCode(block: CustomBlock): string | any[] {
return 'Not implemented';
}

toPythonCode(block: CustomBlock): string | any[] {
return 'Not implemented';
}


 }
Giannis
  • 1,790
  • 1
  • 11
  • 29

1 Answers1

0

Given this was issue was raised a year ago, on the off chance this is still an issue or if someone faces the same issue in the future make sure you are binding you custom blocks in the html:

<ngx-blockly [config]="config" [customBlocks]="this.customBlocks" (javascriptCode)="onCode($event)"></ngx-blockly>
Andrew Stevenson
  • 13
  • 1
  • 1
  • 4