To do this, you must use the closing actions.
Link to the calling action
controller
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
selectorsData: [
{ name: 'mike', value: '1', action: 'alert', options: ["1", "2"] },
{ name: 'steve', value: '2', action: 'alert', options: ["1", "2"] }
],
actions: {
alert(value, name, target) {
alert("Hello: " + value + " - " + name + "-" + target);
}
}
});
Template
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{#each selectorsData as |selectorItem|}}
<label>{{selectorItem.name}}</label>
<select onchange={{action (action selectorItem.action selectorItem.value selectorItem.name) value="target.value"}}>
{{#each selectorItem.options as |option|}}
<option value={{option}}>{{option}}</option
{{/each}}
</select>
<br>
{{/each}}
Twiddle
source
share