suman goud suman goud - 1 month ago 9
AngularJS Question

How to calculate summary of result in Total result from table row

am able to calculate two inputs and saving result in result input and adding new row ,
but i want to calculate summary of result values in total Result(this input is outside of tr)

[here is my code][1],js,output


Move the

$scope.Total = total

out of the for loop and place


at the end of the addRow1 function

Your function should look like below

$scope.addRow1 = function (index) {
      $scope.rvm[index].result = $scope.rvm[index].val1 - $scope.rvm[index].val2;
        var total = 0;
        for (var i = 0; i < $scope.rvm.length; i++) {
          total += parseInt($scope.rvm[i].result);

      $scope.Total = total;