0
Ember Dataと協力して、それぞれの割引が適用されたストア内のすべての商品の合計と等しい計算されたプロパティを作成しようとしています。私は連鎖を約束するために新しいです、そして、私はこの連鎖をどのようにフォーマットしているのかという問題であると信じています。Ember Promiseチェーンが返されない合計
export default DS.Model.extend({
title: DS.attr('string'),
storeProducts: DS.hasMany('storeProduct',{async:true}),
totalStoreValue:function(){
store.get('storeProducts').then(function(storeProducts){ //async call 1
return storeProducts.reduce(function(previousValue, storeProduct){ //begin sum
return storeProduct.get('product').then(function(product){ //async call 2
let price = product.get('price');
let discount = storeProduct.get('discount');
return previousValue + (price * discount);
});
},0);
}).then(function(result){ //
return result;
});
}.property('[email protected]'),
ご協力いただきありがとうございます。
ちょうど私が必要なもの。ありがとうございます! –