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