$scope.total = function() {
var total = 0;
angular.forEach($scope.newArray.items, function(item) {
total += item.totalItem;
})
return total;
}
var appElement = document.querySelector('[ng-controller=SearchCtrl]');
var $scope = angular.element(appElement).scope();
$scope.total = function() {
var total = 0;
angular.forEach($scope.newArray, function(item) {
total += item.kkal;
})
return total;
}
$scope.total(); //answer