1
I have the following function:
$scope.calcularTotal = function(startDate, endDate){
$scope.items = $filter('betweenDate')($scope.items, 'dataPagamento', startDate, endDate);
console.log("testee: "+$scope.items)
var total = 0;
var glosa = 0;
var lote = 0;
angular.forEach($scope.items, function(item) {
total += (item.totalLiquido);
glosa +=(item.totalGlosa);
lote +=(item.totalLote);
});
$scope.totalLiquido = total;
$scope.totalGlosa = glosa;
$scope.totalLote = lote;
console.log("Total: "+$scope.total)
$state.go('tabs.facts', {}, {reload: true});
}
In this function I go through an Array and sum the values. In console.log
that has at the end the total appears correctly. However when I try to do the Data Binding on my page the values do not appear:
This is the page:
ion-view title="Totais" cache-view="false">
<ion-content has-header="true" padding="true">
<h3 style="text-align:center">Total</h3>
<p style="margin-top:30px;font-weight:bold;color: #0066FF">Total Lote: {{totalLote | currency}}</p>
<p style="font-weight:bold;color: #990000">Total Glosa: {{totalGlosa | currency}}</p>
<p style="font-weight:bold;color: #339900">Total Líquido: {{totalLiquido | currency}}</p>
</br>
</br>
</br>
</br>
<p>
<a class="button icon ion-home" href="#/tab/home" style="width:100%"> Home</a>
</p>
</ion-content>
</ion-view>
And that’s the result:
How could I solve this problem?
You printed only $Scope.total. Put the other values also
– Emir Marques
I put and all are printed on the console @Emirmarques. However they do not appear on the page
– DiegoAugusto
At a glance: http://i.stack.Imgur.com/8k3dg.png
– DiegoAugusto
Try without the filter currency
– Emir Marques
Also not working @Emirmarques
– DiegoAugusto
The strange thing is that when I put this bit inside the calculator functionTotals inside another function that I have to load along with the page works, but does not do what I want.
– DiegoAugusto
I think the problem is to accomplish all this when I click on a button and already move to another page. Maybe the page is not being updated :/
– DiegoAugusto
Reload : true is not forcing reload? Pass as false
– Emir Marques
Nothing has changed. Another strange fact, when I declare the variables at the beginning of the page, ex: $Scope.totalLiquido = ""; appears the value 0 dai.
– DiegoAugusto