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.
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');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.