I have a radio-button.js component, a controller radio-options.js, and the radio-options.hbs template. I need to call the optionChanged function that is of the controller in the component, currently the form that is gives the following error: Uncaught Error: had the handler action for: optionChanged
COMPONENT
import Ember from 'ember';
var RadioView = Ember.Component.extend({
tagName: 'input',
type: 'radio',
attributeBindings: ['type', 'htmlChecked:checked', 'value', 'name'],
change: function(){
this.set('selectedValue', this.get('value'));
this.sendAction('optionChanged', this.get('value'));
},
htmlChecked: function(){
return this.get('value') === this.get('selectedValue');
}.property('value', 'selectedValue'),
setupBindings: function() {
if (this.binding) {
this.binding.disconnect(this);
}
this.binding = Ember.Binding.from("context." + this.get('checked')).to('selectedValue');
this.binding.connect(this);
}.on('init').observes('checked', 'context')
});
export default RadioView;
CONTROLLER
import Ember from 'ember';
var RadioOptionsController = Ember.Controller.extend({
answer: Ember.computed.alias('parentController.answer'),
radioName: function(){
return 'question-' + this.get('parentController.model.id');
}.property('parentController.model'),
actions: {
optionChanged: function(selectedValue) {
console.log('value: '+selectedValue);
this.get('answer').set('text', selectedValue);
this.send('saveAnswer');
}
}
});
export default RadioOptionsController;
TEMPLATE
{{#each model as |option|}}
<li>
<label>{{radio-button name=radioName checked='answer.text' value=option.text}} {{option.text}}</label>
</li>
{{/each}}