Creating context menu for go.Node templates


#1

hi, i have a problem with gojs nodes context menus integration in Angular 7.
i have this code snippet that throws me an error a strange Error
Code:
this.diagram.nodeTemplate.contextMenu =
this.('ContextMenu', this.(‘ContextMenuButton’,
this.$(go.TextBlock, ‘Edit Tasks’), { click: myModal.show()}
)
);
Error:

Argument of type ‘“ContextMenuButton”’ is not assignable to parameter of type ConstructorType <string>’.

i really don’t have any idea why, i am following your samples from github.
any help is much appreciated
PS: this.$ is a shorthand for go.GraphObject.make;


#2

Which version of GoJS are you using? We recently made some changes to the TS declarations file to be more strict with GraphObject.make. These changes are in the changelog.

You should be able to resolve the issue by using

this.diagram.nodeTemplate.contextMenu =
  this.$<go.Adornment>('ContextMenu',
    this.$<go.Panel>('ContextMenuButton',
      ...
    )
  );


#3

thank you man! this works