1๐
โ
Use arrow function to define toggleLegendClickHandler
function It will point to component object
export class ChartComponent{
legend: {onClick: this.toggleLegendClickHandler}
toggleLegendClickHandler = ()=>{
...
}
}
0๐
You can use this
shadow,
suppose this is your code,
chartFunction() {
const _that = this; // creating shadow of this
createChart({
data: {
legend: {
onClick: _that.toggleLegendClickHandler
}
}
});
}
now it will refer the component class reference.
Source:stackexchange.com