ng-repeat - count within html loop

前端 未结 4 1557
后悔当初
后悔当初 2021-01-02 20:04

Is there anyway to count an item, then display it outside of the loop?


   value.total
         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 20:53

    You could always do this in your JS function.

            $scope.values = data;
            angular.forEach($scope.values,function(value){
              $scope.total += value.value;
            });
    

    Working plunker: http://plnkr.co/edit/5WZ9alCXzq115wi3xl4B?p=preview

提交回复
热议问题