0
I’m developing an app with Ionic 3 and Firebase. I am facing problems, because it is not decreasing the value of the product(chosen) of the total. Always subtract the last value informed. Follows the code :
deleteProduto(element) {
if(this.vetCarrinho.length > 1){
this.vetCarrinho.splice(this.vetCarrinho.indexOf(element), 1);
this.acum = (this.acum - this.valTot);
this.pedido.total = element;
save function :
irParaCarrinho(element) {
element = this.pedido.carrinho;
this.vetCarrinho.push(element);
console.log(this.vetCarrinho);
this.pedido.carrinho = this.vetCarrinho;
for (let i = 0; i < this.vetCarrinho.length; i++) {
this.acumulador = this.valTot;
}
this.acum += this.acumulador;
this.pedido.total = this.acum;
this.desabilitar = true;
Which variable is returning wrong value? Is the
this.acum
? What is thethis.valTot
? Shouldn’t it be the value of the element? Something likeelement.valor
.– Renata
The products have the total value (this.valTot) that would be, the sale price x quantity. In the list of products, when I try to exclude a product, it always decreases from the total, this.valTot, from the last element.
– user125721
I believe that it would be best to check the total value of the element within the function
deleteProduto(element)
, which is where you tell which element will be deleted. The variableelement
stores the total value or selling price and quantity of the product?– Renata
I am storing the products informed, in a vector, but I am not stating their price. I analyzed coldly and saw that the mistake is this. Here is another question: How do I store the product and its price in the vector, and then subtract the value of the chosen element ?
– user125721
If you post the rest of the code it is easier to understand your problem. For example, where does the
element
?– Renata
I edited the question
– user125721