0
HTML代碼:如何在ng bind中獲得單列值的總和?
這裏是我的HTML代碼,我綁定TOTAL每列THROUGH NG BIND作者:SUM ....
<tr >
<td> Totals </td>
<td> {{total ||'0'}}</td>
<td>{{sum(user.creditTotal)}}</td>
<td>{{sum(user.cardTotal)}}</td>
<td>{{sum(user.saleAmount)}}</td>
</tr>
JS:
我已經聲明範圍變量GET總計總數。任何人都可以幫助我解決我在其中犯的錯誤。 AND(數據)我在哪裏取出由API ...
$scope.total = function() {
$scope.cashTotal =0;
$scope.creditTotal =0;
$scope.cardTotal =0;
angular.forEach($scope.data, function(user) {
$scope.cashTotal = sum(user.cashAmount);
$scope.creditTotal = sum(user.creditAmount);
$scope.cardTotal =sum(user.cardAmount);
})
return cashTotal,creditTotal,cardTotal;
}
可以顯示的$ scope.data – omer
一個例子,也許這將工作,https://jsfiddle.net/suunyz3e/1414 /,我觸發了全部函數,並且還從forEach函數返回了正確的值並將其呈現在視圖中。 – omer