Reputation: 2729
I'm using ember-cli and want to select binding value
{{view Ember.Select
content=industries
value=industryId
optionValuePath="content.id"
optionLabelPath="content.name"}}
inside route I sutup industries
var industries= [];
Ember.$.getJSON('/api/v1/Industry',function(items){
items.forEach(function(item) {
industries.pushObject({id:item.id,name:item.name});
});
});
controller.set('industries', industries);
I have dynamic model, returns from server, property 'industryId' returns 2, but there always is selected element with id=1
Update
{{view Ember.Select
content=industries
value=2
optionValuePath="content.id"
optionLabelPath="content.name"
}}
but is still not selected
Upvotes: 0
Views: 512
Reputation:
If the property industryId is present in the view, then you have to use view.industryId instead of just industryId. If it is already present in the controller and you still don't get it, then you use valueBinding="industryId" instead of value=industryId
Upvotes: 0
Reputation: 1654
If you want to set a default "select" option, add the "prompt" property:
{{view Ember.Select
content=industries
value=industryId
optionValuePath="content.id"
optionLabelPath="content.name"
prompt="Please Select One"}}
Upvotes: 1