Tabs badge dont update when scope value changes

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

Do you have a Codepen example of this issue?

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

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

1 Like