0
Good afternoon!
I’m retrieving some values from mongodb and summed to display the result on screen, but the code has looped.
Someone could help me!
Follows the code!
get recuperaValorTotal(){
let valorTotal: Array<any> = [];
for(let contas of this.contasService.contas){
valorTotal.push({
valor: contas.valorTotal
});
this.valorCalculado += parseFloat(contas.valorTotal.toString());
}
Swal.fire('Valor Total: ' + 'R$' + this.valorCalculado.toFixed(2));
return this.valorCalculado.toFixed(2);
}
In this.countsService.contas I have the following fields:
export class ContasService {
selectConta: Contas = {
_id: '',
descricao: '',
valorTotal: '',
vencimento: '',
status: ''
};
contas: Contas[];
A JSON
{
"descricao": "teste",
"valorTotal" : "200.00",
"vencimento" : "2021-01-19",
"status" : "Pendente"
}
Supplement your code better so we can better understand what’s in this.account variable.
– Julyano Felipe