tabBadge - Not updating


#1

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.


#2

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


#3

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.


#4

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


#5

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);
}


#6

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


#7

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


#8

please help us … facing same issue . :cold_sweat:


#9

not working …plzz help


#10

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


#11

@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.


#12

Thanks Tony, everything is fine for me now.