Issue
This is my chartJS onclick event handler in angular:
legend: {
onClick: this.toggleLegendClickHandler
From that method I need to update a chart after y scale title text is changed. I would like to do this like this._chart.chart.update() where _chart is childview angular directive.
However, this is not a component object but Legend object which received an event. Can I have this in that handler as angular component object?
Solution
Use arrow function to define toggleLegendClickHandler function It will point to component object
export class ChartComponent{
legend: {onClick: this.toggleLegendClickHandler}
toggleLegendClickHandler = ()=>{
...
}
}
Answered By - Chellappan வ
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.