tabBadge - Not updating

Hello,

I have an ion-tab with a tabBadge that updates dynamically at a set interval. The badge on the tab doesn’t update unless I explicitly navigate to another tab.

Html

<ion-tab [root]="tab5Root" tabTitle="CONTATTI" tabIcon="contatti" [tabBadge]="userData.unreadMessages"></ion-tab>

TS

Observable.interval(600).subscribe(()=>{
    /*Inside the following function I update 'unreadMessages' property.*/
    this.userData.getUserMessages(); 
});

Am I doing something wrong ?

Thanks for the help.

1 Like

I have the exact same issue. It seems to be something related to Ionic.

As a workaround for now, I am using the NgZone to explicitly invoke the update… I guess it’s similar to digest in Angular 1.

Could you please post an example how you solved this? That would help me alot.
Thanks!

Here’s an example. Hope it helps

import { Component, NgZone } from '@angular/core';
constructor(private _zone: NgZone) {
}
your_method(){
    this._zone.run(() => item.checked = true);
}

The problem still exists in RC3.
@mhartington any solutions other than explicitly invoke the zone run?

Looks like tabBadge is only a set input, and cannot be changed unless you call zone.
Can someone open an issue about this

please help us … facing same issue . :cold_sweat:

not working …plzz help

Has it been fixed? I’m having a similar problem.

@Thesurya9 @skinny_jones If you are still facing this issue, open an issue with the ionic team and they’ll help guide you. For now try using the _zone example explained above. Post your code as well if you need help.

1 Like

Thanks Tony, everything is fine for me now.