I need to get the grand total price of all the objects returned from a JSON API.
my idea is to create a controller and set a property on it. Then grab the model loop over each object and add to the predefined property that objects total price. Something like this:
export default Ember.Controller.extend({
orderTotal: 0,
getOrderTotal: function(){
var model = this.get('model');
model.forEach(function(c){
var order_total = this.get('orderTotal') * c.total_price;
this.set('orderTotal', order_total)
});
}
});
problem is I can't get the model. How can I access the model inside a controller?
Aucun commentaire:
Enregistrer un commentaire