Problems saving two information at the same array position

Asked

Viewed 32 times

0

Well, I’m developing an app with ionic 3. I am facing problems, because I need to show in the same column, the product and its value :

Product - 350 (value)

But, it is storing at position 1, the product, and at position 2 its value.

Follows the code TS:

  for (let i = 0; i <= this.vetValores.length; i++) {

    if (this.vetValores.indexOf(element, this.valTot)) {
      this.vetValores.push(element, this.valTot);
      this.vetValores[i + 1];
      break;
    }

Code HTML :

 <ion-list>
            <ion-item *ngFor="let prod of vetValores">
             <ion-row>            
                  {{prod}} {{prod.valTot}} 
              </ion-row>

            </ion-item>
   </ion-list>
  • what you have in element?

  • Element equals the informed product

  • 1

    I think the ideal would be for you to create an attribute in the product called Total Value and put this.valTot in this attribute, because the way you are using the push, it will show how you are saying this showing, one after the other, because the push accepts N elements: https://www.tutorialspoint.com/typescript/typescript_array_push.htm

  • Let val = this.valTot; if (this.vetCarrinhoAux.indexof(element, val) === -1) { this.vetCarrinho.push(element, val);

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.