Such a controller:

.controller('ArticlesCtrl', function($scope){ $scope.sum = function(value) { return value.reduce(function(total, article) {return total + article.price;}, 0); }; }) 

And such a json

 [ {"id": "1", "name": "Pizza Vegetaria", "price": 5 }, {"id": "2", "name": "Pizza Salami", "price": 5.5 }, {"id": "3", "name": "Pizza Thunfisch", "price": 6 }, {"id": "4", "name": "Pizza Salami", "price": 5.5 }, {"id": "5", "name": "Pizza Thunfisch", "price": 6 } ] 

When this works and the amount is considered. 28, - rubles

But the firebug console shows an error.

 watch.js (строка 59) GET http://192.168.1.136:6543/www/an/articles.json angular.js (строка 10413) Error: value is undefined $scope.sum@http://192.168.1.136:6543/www/an/app.js:43:36 anonymous/fn@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js line 13036 > Function:2:276 expressionInputWatch@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js:14014:31 $RootScopeProvider/this.$get</Scope.prototype.$digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js:15548:34 $RootScopeProvider/this.$get</Scope.prototype.$apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js:15824:13 done@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js:10263:36 completeRequest@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js:10435:7 requestLoaded@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js:10376:1 return logFn.apply(console, args); 
  • Where is the question? - Saidolim
  • How to remove the error, why is it? - Vlad
  • add markup where this method is called - Grundy

0