How to access ViewChild variable inside DiagramListener

How to call constructor variable inside gojs listener function
Ex:

import { MatDialog } from ‘@angular/material/dialog’;

export class AppComponent{

@ViewChild(‘dialog’) public dialog: matDialog;

public ngAfterViewInit() {

if (this.observedDiagram) return;

this.observedDiagram = this.myDiagramComponent.diagram;

this.cdr.detectChanges();

const appComp: AppComponent = this;

// listener for inspector

this.myDiagramComponent.diagram.addDiagramListener('ChangedSelection', function(e) {

  if (e.diagram.selection.count === 0) {

    appComp.selectedNode = null;

  }

  const node = e.diagram.selection.first();

  if (node instanceof go.Node) {
    //How to pass dialog variable here inside the function
    appComp.selectedNode = node;

  } else {

    appComp.selectedNode = null;

  }

});

}

}

If you change the “ChangedSelection” DiagramEvent listener to be an arrow function, are you able to refer to your dialog property?