-2
I am a beginner in German and I have the following problem and I don’t know how to solve it!
I have a table and I need to calculate the total waste adding up all prices. Inside ng-repeat has a column where it displays all the values of residuals, but I don’t know the syntax to read these column items and add.
Someone could help me?
$scope.somarValores = function(){
$scope.total = $scope.pedidos.residuoModel.preco + $scope.pedidos.residuoModel.preco
}
<tbody>
<tr ng-repeat="pedidosTabela in pedidos | filter: pesquisaPed"ng-click="selecionaPedido(pedidosTabela)">
<td>{{pedidosTabela.id}}</td>
<td>{{pedidosTabela.data}}</td>
<td>{{pedidosTabela.fornecedorModel.nome}}</td>
<td>{{pedidosTabela.categoriaModel.nome}}</td>
<td>{{pedidosTabela.residuoModel.nome}}</td>
<td>{{pedidosTabela.residuoModel.status}}</td>
<td>{{pedidosTabela.residuoModel.preco | currency}}</td>
<td>{{pedidosTabela.residuoModel.peso}}</td>
<td>{{pedidosTabela.residuoModel.situac}}</td>
<td><label ="{{pedidosTabela.residuoModel.preco}+{{pedidosTabela.residuoModel.preco}}"/></td>
</tr>
</tbody>
<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Total: {{total}}</th>
</tr>
</thead>
<br><br><br><br>
<a class="btn btn-success" ng-click="somarValores()" role="button" placeholder="">Totalizadores </a>
or a reduce: https://medium.com/@raullesteves/javascript-understanding-the-reduce-once-for-all-c4cbaa16e380
– cezar
I didn’t know the reduce, I think it’s better than a for.
– Matheus Barni
Matheus Barni It worked for me!!! thank you very much dude you are the dude bro
– J L Neto
Cezar thanks also for the tip, I will test this way too, a hug!
– J L Neto