Tab badge does not update until you switch the tab

Hi all,

I add notification and handle the receive notification event in app.js–>$ionicPlatform.ready function. The tab has its own tabCtrl and tab Badge gets the value from the badgeService.

Once you receive the notification, in app.js–>$ionicPlatform.ready–>onReceive func, it will update the service badge value.

But now the problem is that after you update the badge number by badgeService in app.js, the tab badge does not get updated right away, but when you switch to the other tab, it will update.

So why the service data change does not update the tabCtrl Scope value? Is it because updating the service badge in app.js does not trigger tabCtrl?

BTW, I bind the tab badge value through service function just to avoid the $broadcast , I have tried $broadcast in app.js and $on in the tabCtrl, this works, but I’m afraid this is not the best practice.

Here is how I define the tabCtrl:
function ( $scope, $rootScope, badgeService) {
$scope.badges =function(){
return badgeService.setBadgeCount();


app.factory(‘badgeService’, function ($rootScope, localStorageService) {
var setBadgeCount = function () {
var count = 0;
var badgeInfos = localStorageService.get(‘badgeInfo’);
if (badgeInfos) {
for (var i = 0; i < badgeInfos.length; i++) {
count += badgeInfos[i].msgInfos.length;

    if (count > 0 && count <= 99) {
        return count.toString();
    } else if (count > 99) {
        return "99+";
    } else {
        return "";

return {
    setBadgeCount: setBadgeCount


$ionicPlatform.ready(function () {
var onReceiveNotification = function(){