Accessing Class variables/methods in Callbacks

Tags: #<Tag:0x00007f8b1ddf1e20>

Hi,

I am using Handsontable 7.0. In my angular component I want to access class data from the callback.

So for example assume I have the following code in the component.ts file. As you will see in the code below since I want I access the dataArray variable inside callback, I have defined the callback as arrow function.

export class TestComponent implements OnInit {

// I want to access below variable in the callback
dataArray:Array< string>= new Array();

constructor() { }
ngOnInit() {
Handsontable.renderers.registerRenderer(‘dropdownRenderer’, this.dropdownRenderer);
}

// call back definition

dropdownRenderer=(instance, td, row, col, prop, value, cellProperties)=> {

Handsontable.renderers.DropdownRenderer.apply(this,arguments);

    // i need to access  dataArray variable here.

return td;

}

}

Issues:

1-The statement Handsontable.renderers.DropdownRenderer.apply(this, arguments) is throwing error, because arguments is not allowed in arrow functions. And also what about ‘this’ in apply as it is now an arrow function.

2-Inside this callback how I can access dataArray variable?.

Thanks

Hi ,

Please ignore this topic and can be closed. I have solved this in the way the following link demonstrates.

Thanks

Thank you for an update.