Get pointer to controller in click event


#1

I defined a chart properties in the controller . in the event property the controller property is undefined

How can I get access to the controller in click event in chart ?


#2

make chartData a computed property, that way you have access to the controller’s this as you build your object.

import Ember from 'ember';
const { computed } = Ember;
export default Ember.Controller.extend({
  chartData: computed(function() {
    return [{
      point: {
        events: {
          click: () => {
            this.onClick();
          }
        }
      }
    }];
  }),

  onClick() {
    console.log('onClick() called');
  }
});