Accessing Angular Method inside InitDiagram()

I am trying to call an angular method (this.showNodeDetails method) whenever I click a ContextMenu button but it seems for some reason I cannot access the angular method inside initDiagram(). Kindly help me on this. Here is a piece of code inside initDiagram.

 dia.nodeTemplate =
      $(go.Node, 'Spot',
                $(go.TextBlock, 'View Details'),
                  click: (e, obj) => {
                    const contextmenu = obj.part;
                    const nodedata =;
                }, new go.Binding('visible', '',
                  (o: any) => {
                    return o.diagram.selection.count === 1;

You probably need to bind this in your initDiagram method so you can access your component’s methods.

So you could add the following to your component class:

  constructor() {
    this.initDiagram = this.initDiagram.bind(this);