SendAction from component to controlller

Hi, I have a date-picker. So I want to pass values on focus-out.

Component hbs:

{{input type=“text” name=“start” value=rangeStart focus-out=‘selectedRangeOption’'}}

Component js:

export default Ember.Component.extend({
  init(){
    this._super(...arguments);
  },
  didInsertElement: function () {
    this._super(...arguments);
    this.$('.input-daterange').datepicker({
      format: "dd/mm/yyyy"
    });
  },
  actions:{
    selectedRangeOption(val){
      this.sendAction('selectedRangeOption', val);
    }
  }
});

Controller:

export default Ember.Controller.extend({
 actions: {
    selectedRangeOption(val){
      console.log('e selectedRange', val);
    }
  }
});

What am I doing wrong? I need values in controller.

Did you register selectedRangeOption on component?

Like : {{date-picker selectedRangeOption=selectedRangeOption}}

1 Like

What do you mean? In Component I have like this:

{{input type="text" name="start" value=rangeStart focus-out="selectedRangeOption"}}

No, I mean how you call your component

1 Like

Thank you jmimi, I’ve got the point. Problem was in component calling.

1 Like