SendAction from component to controlller


#1

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.


#2

Did you register selectedRangeOption on component?

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


#3

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

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


#4

No, I mean how you call your component


#5

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