Emit from $rootScope


#1

i have $rootScope.$emit('setReturnedlast'); in a service and in a controller:

   $rootScope.$on('setReturnedlast', function() {                                                                                                  
          alert('test');                                                                                                                     
          $scope.returnedLast = true;                                                                                                                 
      });         

but its doesnt fire, what can it be? i am making this because i wait for many promises but this is a fnction that goes async downloading files so it finishes very last and i need to know when for getting rid of a preloader.


#2

Try broadcast instead of emit.


#3

didnt work either but i finally got it working with callbacks. if for someone i can help my preloader is in css and its in the current page i was redirected to. so this animation its shown by an <div class="cat-btns-container containter with the info" ng-if="$root.returnedone"> blah....<div class="cat-btns-container containter with the preloader" ng-if="!$root.returnedone"> and in the callback last function:

$rootScope.returnedone = true;
$state.go($state.current, {}, {reload: true});