0

Такой контроллер:

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

И такой 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 }
]

При этов все работает и сумма считается. 28,- руб.

Но консоль firebug показывает ошибку.

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);
3
  • а где сам вопрос?
    – Saidolim
    26 дек 2015 в 17:36
  • Как убрать ошибку, почему она?
    – Vlad
    26 дек 2015 в 18:06
  • добавьте разметку где вызывается этот метод
    – Grundy
    27 дек 2015 в 9:14

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.