[英]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
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.