0
我有一个基本订单输入表单,其中包含帐单和送货地址字段(均基于“地址”模型)。我有一个复选框,上面写着“帐单地址和发货一样?”如果选中,则会将帐单地址数据复制到送货地址。余烬:将模型数据复制到另一个
我会怎么做呢?这对我来说不是很明显。我在考虑点击“下一步”按钮时,如果“billShipSame”值= true,则复制数据。但是,您如何实际复制数据?或者我刚刚接近这个问题错了?
这个模型看起来像:
export default DS.Model.extend(Validations, {
type: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
address1: attr('string'),
address2: attr('string'),
city: attr('string'),
state: attr('string'),
country: attr('string'),
postalCode: attr('string'),
phone: attr('string')
});
而且这里有我如何使用它们的精简版本:
billingAddress: computed(function() {
return this.get('store').createRecord('address', { type: 'billing'});
}),
shippingAddress: computed(function() {
return this.get('store').createRecord('address', { type: 'shipping'});
}),
orderModel: computed(function() {
return this.get('store').createRecord('order', {
billingAddress: this.get('billingAddress'),
shippingAddress: this.get('shippingAddress')
});
}),
那么,“与计费相同”默认为yes(因为大多数购物者都会这样)。但我的问题是,从一个模型到另一个模型复制数据的语法是什么? – tarponjargon
啊,没有意识到:-)更新了我的答案 – acorncom