繁体   English   中英

如何通过单击事件传递值Ember Js Controller

[英]How to Pass Value Ember Js Controller with out click Event

** strong text **灰烬中如何传递值控制器

<div>
{{view  "select"  content=model    prompt="Please select a name"  selectionBinding="App.selectedComboBoxController.model"  optionValuePath="content.fullName" optionLabelPath="content.title"  }}

    </div>

    -
    <p>
        Selected: {{App.selectedComboBoxController.model.title}}
</p>

以上代码我得到正确的输出。 但是我想要将该值传递给控制器​​而无需任何按钮

**Here my controller.**

App.ComboBoxController = Ember.Controller.extend({

});

需要将将保存所选值的控制器与当前上下文相关联。 因此,在下面的示例中,假定当前上下文是索引路由,并且模型返回对象数组。

血红蛋白

<script type="text/x-handlebars" data-template-name="index">
  <div>
   {{view  "select"  content=model    prompt="Please select a name"  selectionBinding="controllers.selectedComboBox.model"  optionValuePath="content.fullName" optionLabelPath="content.title"  }}
</div>

    -

    <p>
        Selected: {{controllers.selectedComboBox.model.title}}
</p>
  </script>

js

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return [
      {fullName:"the full name1", title:"the title1"},
      {fullName:"the full name2", title:"the title2"},
      {fullName:"the full name3", title:"the title3"}
    ];
  }
});

App.IndexController = Em.ArrayController.extend({
  needs:["selectedComboBox"]

});

App.SelectedComboBoxController = Em.ObjectController.extend({
  model:null
});

http://emberjs.jsbin.com/jodaqumoba

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM