首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ember.select选择值

Ember.select选择值
EN

Stack Overflow用户
提问于 2014-07-21 16:39:21
回答 2查看 505关注 0票数 0

我使用成员-cli,并希望选择绑定值

代码语言:javascript
复制
  {{view Ember.Select
      content=industries
      value=industryId         
      optionValuePath="content.id"
      optionLabelPath="content.name"}}

内线I支援工业

代码语言:javascript
复制
   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); 

我有动态模型,从服务器返回,属性'industryId‘返回2,但是在id=1中总是有选定的元素

更新

代码语言:javascript
复制
  {{view Ember.Select
      content=industries   
      value=2   
      optionValuePath="content.id"
      optionLabelPath="content.name"
       }}

但仍未被选中

EN

回答 2

Stack Overflow用户

发布于 2014-07-21 16:59:56

如果要设置默认的"select“选项,请添加”提示“属性:

代码语言:javascript
复制
{{view Ember.Select
      content=industries
      value=industryId         
      optionValuePath="content.id"
      optionLabelPath="content.name"
      prompt="Please Select One"}}
票数 1
EN

Stack Overflow用户

发布于 2014-07-21 18:03:58

如果视图中存在属性industryId,则必须使用industryId而不是仅使用industryId。如果它已经存在于控制器中,而您仍然没有得到它,那么您将使用valueBinding="industryId"而不是value=industryId

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24870236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档