-1

I have table

<table class="table">
    <thead>
        <tr>
            <th>N0</th>
            <th>Produrce</th>
            <th>Price</th>
            <th>Unit</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="paym in prices">
            <td>{{paym.num}}</td>
            <td>{{paym.name}}</td>
            <td>{{paym.payment}}</td>
            <td>{{paym.unit}}</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2"><span class="sp-total-lbl"> Total Amount</span></td>
            <td align="right"><span id="span-amount">{{getTotal())}}</span></td>
        </tr>
        <tr>
            <td colspan="4">
                <button ng-click="check_verify()" class="btn-primary">
                    <i class="material-icons">add</i>Check
                </button>
            </td>
        </tr>
    </tfoot>
</table>

Here is getTotal() function

$scope.getTotal =function(){
 var total = 0;
 for(var i = 0; i < $scope.prices.length; i++){
    var p = $scope.prices[i];
    total += parseInt(p.payment);
 }
 return total;
}

What my question? I want ask when I click button Check call function check_verify() , I want alert total price.

$scope.check_verify =function(){
    alert($scope.getTotal);
}

I trying like this but it not get result data, it return function code, Any one seguest me how to get valus data from total price?

KavehG
  • 294
  • 1
  • 2
  • 11
koe
  • 686
  • 1
  • 11
  • 30

1 Answers1

1

You forgot the () to make the function call.

$scope.check_verify =function(){
    alert($scope.getTotal());
}
Mike Tung
  • 4,242
  • 1
  • 12
  • 20