im试图保存几个具有一对一关系的模型,该关系在单个控制器操作上初始化。我把事情分成几个小函数来使用promise。我已经试着让它工作了将近一个星期,但找不到解决方案。我还制作了一个jsbin:http://jsbin.com/enoYONAv/1/edit
您可以在Ember.Select
中使用selectionBinding
而不是valueBinding
,直接检索所选模型,而不是您的id。例如:
{{
view Ember.Select
prompt="Gender"
contentBinding="genders"
optionValuePath="content.id"
optionLabelPath="content.type"
selectionBinding="selectedGender"
}}
所以在你的行动中你可以做到:
var gender = this.get('selectedGender');
...
var hash = {
name : personName,
gender : gender,
organization : organization
};
this.savePerson(hash).then(this.saveAgentAssociation(agentAddress));
这是您更新的jsbin,请看一下http://jsbin.com/efeReDer/1/edit