Calculate with Ngfor


#1

I am using ionic 2.

I Developed E-commerce app.

Here is my template(Cart Page).

PRICE_REGULAR is Product Regular price and PRICE_SALE is product sale price.If I need to increase the product quantity I call the method countOperator(1,p)

Price is Quantity and PRICE_SALE price.

<ion-row class="apply-coupon" *ngFor="let p of Cartproducts;let i=index">
                <ion-col col-4>
                    <img src="{{p.P_IMAGES[0].URL}}" alt="product2">
                </ion-col>
                <ion-col col-8>
                    <h1>{{p.P_TITLE}}</h1>
                    <p class="subtitle">Subtitle</p>
                    <p class="code">Code: 123</p>

                    <div>
                        <ion-row>
                            <ion-col width-50>
                                <button ion-button outline small><ion-icon name="add" (click)="countOperator(1,p)"></ion-icon></button>
                            </ion-col>
                            <ion-label text-center>{{count}}</ion-label>
                            <ion-col width-50>
                                <button ion-button outline small><ion-icon name="remove" (click)="countOperator(-1,p)"></ion-icon></button>
                            </ion-col>
                        </ion-row>  
                        <span><img src="./assets/images/rupee-black.svg" alt="Rupee">{{p.PRICE_REGULAR}}</span>

                        <span *ngIf="Pid == p.C_ID"><img src="./assets/images/rupee-black.svg" alt="Rupee">{{Price}}</span>


                        <span text-right><img src="./assets/images/rupee-black.svg" alt="Rupee">{{p.PRICE_SALE}}</span>
                    </div>

                    <div>
                        <button (click)="cancel(i)">Cancel X</button>
                    </div>
                </ion-col>  
            </ion-row>

Here is my countOperator method

countOperator(operator,s){

if(this.count >= 1){
      this.show1=false;
      this.count += operator;
      this.Price=this.count * Amount;
      this.change2(this.Price);
    }
    if(this.count < 1){
      this.show1=false;
      this.count = 1;
      this.Price=this.count * Amount;
      this.change2(this.Price);
    }
}

I need dynamically calculate Total amount .


#2

i dont understand, what type of object do you take exactly and what result do you expect?