我创建了一个购物车。我使用夹具适配器。我的模型
App.Clothing = DS.Model.extend({
name: DS.attr('string')
, category: DS.attr('string')
, img: DS.attr('string')
, price: DS.attr('number')
, num: DS.attr('number')
, fullPrice: function(){
return this.get('price') + " $";
}.property('price')
})
App.CartRecord = App.Clothing.extend({
numInCart:DS.attr('number',{defaultValue:1})
, fullPrice: function(){
return this.get('price')*this.get('numInCart');
}.property('numInCart','price')
})
App.CartRecord.FIXTURES = [];
路线
App.CartRoute = Em.Route.extend({
model: function(){
return this.store.find('cartRecord');
}
})
还有我的控制器
App.CartController = Em.ArrayController.extend({
totalPrice: 0
});
我如何计算总价?