title: How to use $q to get a promise from a $broastcast in angularJS
body: <p>Right now my controller code looks like this:</p>
  
  <pre><code>$scope.spAPI.load(id).then(function(result){
    var deferred = $q.defer();
    if(result !== undefined){
      deferred.resolve($rootScope.$broadcast("onSpLoaded", result));
    }
    return deferred.promise;
  }).then(function(success){
  
        $scope.modalInstance = $modal.open({ ... });
  
  
  });
  </code></pre>
  
  <p>I want the modal instance to be opened AFTER the broadcasts are processed. Is there a way to do this?</p>
  
  <p>Update: I was thinking about this problem backwards. I meant to do the broadcast after the modal instance, anyway, nevermind.</p>
  
  <p>PS: I did have problems with the modalinstance.opened callback though, I had to hack my way around it. I am still struggling to use $q correctly, my code has been getting messier.</p>