score:1

Accepted answer

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();
            }
          }
     });

}

score: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.


Related Query

More Query from same tag