I'm trying to get the selected value from a select tag, I have tried these cases but I'm not able to get the selected value, Does anyone have an idea on what is wrong with the way I'm declaring the action on the select tag?
UPDATE 1
I tried to recreate the problem on ember-twiddle but for some reason it won't run as it does on my project, it seems that ember-twiddle does not read the actions declared on the route. However here is the example:
Case 1
In this case I got an error:
Uncaught TypeError: Cannot read property 'apply' of undefined
Template:
{{#each model.items as |item|}}
<select class="form-control" onchange={{action 'ChangeCombo' item "Price" value='target.value'}}>
<option value="">Select an option</option>
<option value="1000">$1000</option>
<option value="100">$100</option>
<option value="10">$10</option>
</select>
{{/each}}
Route Actions:
actions: {
ChangeCombo(paramOne, paramTwo, paramThree) {
console.info(paramOne, paramTwo, paramThree);
},
}
Case 2
In this case the first parameter is the current Item from de model array, the second one is the string "Price" but the third parameter is undefined and the last parameter which is supposed to be the event object is also undefined.
Console output:
{object}, "Price", undefined, undefined
Template:
{{#each model.items as |item|}}
<select class="form-control" {{action 'ChangeCombo' item "Price" value='target.value' on='change'}}>
<option value="">Select an option</option>
<option value="1000">$1000</option>
<option value="100">$100</option>
<option value="10">$10</option>
</select>
{{/each}}
Route Actions:
actions: {
ChangeCombo(paramOne, paramTwo, paramThree, paramFour) {
console.info(paramOne, paramTwo, paramThree, paramFour);
},
}
Ember version
ember-cli: 3.7.1 node: 10.1.0 os: win32 x64