Cannot read property 'getElementAtEvent' of undefined

I am getting this error when trying to call a function of chart using chart.js, this is how the code looks like, simplified:

    export class TrackerPage {
      @ViewChild('doughnutCanvas') doughnutCanvas;
      doughnutChart: any;

      this.doughnutChart = new Chart(this.doughnutCanvas.nativeElement, {
      type: 'doughnut',
      data: {
        labels: this.titles,
        datasets: [{
          data: this.times,  
      options: {
        onClick: this.timeSlotEdit,

      timeSlotEdit(event, array){
        let activeElement = this.doughnutChart.getElementAtEvent(event);

For those whom still looking for a solution to the same problem,
try appending ‘bind(this)’ to the callback function


options: {
onClick: this.timeSlotEdit.bind(this),