Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 231018

How to fix my ion badge for cart is not updating in real time and requires navigation from other pages to be updated?

$
0
0

Hello,
I suspect a timming problem.
let alert = this.alertCtrl.create({ is a asyncrouns call and is not awaited
this.updateStorage(this.productdetail).catch returns a promise
alert.present(); is a asyncrouns call and is not awaited
this.changeDetector.detectChanges(); maybe the try to fix timming problem with that?

this.storage.get(‘products’).then((data) => { is a promise

async calls return the controll to caller, so the next line of code will executed, but the async call will be executed anywhen.
promises are simillar.

For example: this.alertCtrl.create is exectued async, in between it exectues the next lines of your code. If your async call is not fix enougt, the line alert.present crash with undefined error, because let alert has no value at that time.

Best regards, anna-liebt


Viewing all articles
Browse latest Browse all 231018

Trending Articles



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