app.controller('AdminProvinceReportCtrl', function($rootScope, $scope, $http, $timeout, $state, toaster) { $scope.load = function(){ $scope.myPromise = $http({ url : $rootScope.host_url + '/adminOptr/provinceReport?session=' + $rootScope.session, method : 'GET' }).success(function(data) { if(data.code == 0){ $scope.array = data.result; $scope.summary = {regStd:0, boy:0, girl:0, wen:0, li:0, wenli:0, czyj:0, czwj:0, ncyj:0, ncwj:0, fr:0,ru:0,en:0,de:0,jp:0,sp:0,shengjzx:0,sjzx:0,qtzx:0}; angular.forEach($scope.array, function(item){ $scope.summary.regStd += item.regStd; $scope.summary.boy += item.boy; $scope.summary.girl += item.girl; $scope.summary.wen += item.wen; $scope.summary.li += item.li; $scope.summary.wenli += item.wenli; $scope.summary.czyj += item.czyj; $scope.summary.czwj += item.czwj; $scope.summary.ncyj += item.ncyj; $scope.summary.ncwj += item.ncwj; $scope.summary.fr += item.fr; $scope.summary.ru += item.ru; $scope.summary.en += item.en; $scope.summary.de += item.de; $scope.summary.jp += item.jp; $scope.summary.sp += item.sp; $scope.summary.shengjzx += item.shengjzx; $scope.summary.sjzx += item.sjzx; $scope.summary.qtzx += item.qtzx; }) } }).error(function() { }); } $scope.load(); })