Reputation: 5998
I have the following content for my select options in my controller:
opts: [
{id: 1, code: 'TEST A', desc: 'DESC A', other: 'EXAMPLE A'},
{id: 2, code: 'TEST B', desc: 'DESC B', other: 'EXAMPLE B'},
{id: 3, code: 'TEST C', desc: 'DESC C', other: 'EXAMPLE C'}
],
v: 2,
And this is in my application.hbs
{{view Ember.Select
content=opts
optionValuePath='content.id',
optionLabelPath='content.code'
value=v}}
This renders the select
element with TEST B
as pre-selected.
How do I get the whole object whenever I select a value from the list?
I understand I can get the value through this.get('v')
which returns the value of the select element. Is there a way to get the other properties in the selected object?
Please help.
Upvotes: 1
Views: 47
Reputation: 47367
You van bind to the selection which gives you the object itself
{{view Ember.Select
content=opts
optionValuePath='content.id'
optionLabelPath='content.code'
value=v
selection=foo}}
this.get('foo');
this.get('foo.id');
Example: http://emberjs.jsbin.com/quhov/1/edit
Upvotes: 1