$scope.visible = false;
$scope.visible = true;
$rootScope.$apply(); // why?
Callback registered with
$rootScope.$on is triggered by either $rootScope.$broadcast or $rootScope.$emit. If you explore these methods source code you will see that these methods by itself do not trigger
$digest cycle (dirty-checking). That means, that
$digest should be triggered either by the code that calls
$emit, or inside a callback registered with
Usually, it's better to assume that callback is triggered inside
$digest loop and it means that callback call should be wrapped with
$apply, as in:
This is consistent with what angular best practices suggest:
$scope.$apply() should occur as close to the async event binding as possible.