1👍
✅
Could you try
initializeGraph() {
const that = this;
this.graph = new Chart('graph', {
type: 'pie',
data: {
datasets: [{
data: [1,2],
backgroundColor: ['#RRGGBB', '#FF0000'],
}],
labels: ['blue','red']
},
options: {
onClick : function(event,elements) {
that.hello();
}
}
});
}
0👍
Did you try using arrow function? (e) => {}
The this
variable’s scope is different when using arrow function.
The arrow function inherit the ‘this’ from the parent scope, which in your case might refers to global scope.
Source:stackexchange.com