私は請求と発送先住所フィールド(両方とも '住所'モデルに基づく)を持つ基本注文フォームを持っています。 「請求先住所は配送先と同じですか?」というチェックボックスがあります。これをチェックすると、請求先住所データが配送先住所にコピーされます。ember:モデルデータを別のものにコピー
私はこれをどのように行うのでしょうか?それは私には明らかではありません。私は、 "次の"ボタンがクリックされたときに、 "billShipSame"の値が真であればデータをコピーすると思っています。しかし、実際にどのようにデータをコピーしていますか?あるいは、私はこの問題に間違っているだけですか?
モデルは次のようになります。
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')
});
}),
...それはあなたが後にしているものを扱うべきだと考えています。しかし、私の質問は文字どおり、あるモデルから別のモデルにデータをコピーする構文は何ですか? – tarponjargon
ああ、それを認識していない:-)私の答えを更新 – acorncom