Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

After storing item in storage it is not removing when pressed delete item button

$
0
0

@aditbharadwaj wrote:

Whenever i add any product in wishlist , i can not remove it from wish list unless i log out or clean storage.
the same code i use in for CheckoutCart in that i can add as well as remove products from Checkoutcart array storage.
wish.html


<div class="heading uppercase">
      Products in Your Wishlist
</div>


  <div class="width50" *ngFor="let object of wishdata" text-center style="height:250px">
    <ion-icon name="close-circle" class = "topright" (click)= "deleteitem(object)"></ion-icon>
    <img src="{{object.images[0].src}}" style="height: 70%" (click)="navigateToPage(object.id, object)" />
    <div class="product-name uppercase" padding-top padding-horizontal text-nowrap style="min-width: 0; overflow: hidden; text-overflow: ellipsis;">{{object?.name}}</div>
    <span class="price" *ngIf="object?.meta_data[14]?.key == 'inApp'">&#8377; {{object?.meta_data[14]?.value}}</span>
    <span class="price" *ngIf="!object?.meta_data[14]?.key != 'inApp'">&#8377; {{object?.price}}</span>
  </div>

</ion-content>

Wish.ts code for deleteitem()

async deleteitem(object){
    var index = this.wishdata.indexOf(object);
    if (index > -1) {
      this.wishdata.splice(index, 1);
      await this.storage.set('products', this.wishdata);
    }
    this.navCtrl.setRoot(this.navCtrl.getActive().component);
  }

Cart.html

<div class="width50" *ngFor="let object of cartdata" text-center style="height:250px">
    <ion-icon name="close-circle" class = "topright" (click)= "deleteitem(object)"></ion-icon>
    <img src="{{object.images[0].src}}" style="height: 70%" />
    <div class="product-name uppercase" padding-top padding-horizontal text-nowrap style="min-width: 0; overflow: hidden; text-overflow: ellipsis;">{{object?.name}}</div>
      <span class="price" *ngIf="object?.meta_data[14]?.key == 'inApp'">&#8377; {{object?.meta_data[14]?.value}}</span>
      <span class="price" *ngIf="!object?.meta_data[14]?.key != 'inApp'">&#8377; {{object?.price}}</span><br/>
</div>

cart.ts delete item function

async deleteitem(object){
    var index = this.cartdata.indexOf(object);
    if (index > -1) {
      this.cartdata.splice(index, 1);
      await this.storage.set('products', this.cartdata);
    }
    this.navCtrl.setRoot(this.navCtrl.getActive().component);
  }

Can any1 help what am i doing wrong as the code is similar for both the carts but one works and one does not ?

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>