@aditbharadwaj wrote:
whenever i add any product in the cart, the shopping cart icon doesn’t update in real time to show that a product is added but needs a refresh of the view by navigating to any other page and coming back then only the ion -badge value is set 1.
<button ion-button icon-only (click)="cart()"> <ion-icon name="cart"></ion-icon> <ion-badge id="notifications-badge" style="font-size:1rem" *ngif="ccount">{{ccount}}</ion-badge> </button> //SETTING CART LENGTH this.storage.get('products').then((data) => { if(data != null) this.ccount = data.length; else this.ccount = 0; }); //code after pressing the add to cart button showAlert() { let alert = this.alertCtrl.create({ title: 'Product Added!', subTitle: 'Added To Cart Successfully!', buttons: ['OK'] }); this.updateStorage(this.productdetail).catch(reason = console.error(reason)); alert.present(); this.changeDetector.detectChanges(); }
Posts: 1
Participants: 1