How to trigger a class instance method on click event of modebar button

Below is the code snippet we used in our application. Basicalluy, a custom edit button is added in modebar to allow user to edit the plot data. The click event takes only functions but not class instance method. How to call a method defined in component (typescript-angular component) using this keyword.

config: {
modeBarButtonsToAdd: [
{
name: ‘Edit Plot’,
icon: this.pencilIcon,
direction: ‘up’,
click: function () {
this.edit(); //call class instance delete method
this.ekpiPloDialog = true; //this is a global variable (but the value set here is nt available outside function
console.log(‘Inside chart click’, this.ekpiPloDialog);
},
},
{
name: ‘Delete Plot’,
icon: this.eraseshape,
direction: ‘up’,
click: function (gd) {
alert(‘Delete Callback’); //call this.Delete method not a function
},
},
],
},