Tenho um componente radio-button.js um controller radio-options.js e o template radio-options.hbs. Preciso chamar a função optionChanged que é do controller no componente, atualmente da forma que está dá o seguinte erro: 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}}