Tabs badge dont update when scope value changes


#1

Im having trouble with my badge not updating… Im running a request on interval, the first request gets it right but then the next ones doesnt update it anymore… Im pretty sure its in the right controller and my logic is correct (i did console.log) it will only update when i refresh the page


#2

Do you have a Codepen example of this issue?


#3

Wild guess here. If you are using setTimeout to generate your interval then suggest using Angular’s $timeout instead as this will ensure updates to scope variables are synchronized with the digest cycle.

Other way is to wrap your scope updating code in $scope.apply():

$scope.$apply(function () {
    //update scope here
});

#4

For my tab badges, I used $broadcast and $on because it’s easy and I needed to display these badges in a screen too.