title: AngularJS - How can I know when a promise on a parent controller has been resolved?
body: <p>I have a directive that relies upon data from its parent's controller. This data is returned in a promise. How can I know when the promise, which exists on the parent controller, has been resolved?</p>
  
  <p>Parent Controller </p>
  
  <pre><code>angular.module("UserShoes").controller("UserController", function ($scope) {
    $scope.user = User.get({
      userId: 1 
    });
  
    $scope.shoes = [];
  
    $scope.user.$promise.then(function (data) {
      data.shoes.forEach(function (shoe, index) {
        if (shoe) {
          $scope.shoes.push(shoe);
        }
      });
    });
  });
  </code></pre>
  
  <p>Directive</p>
  
  <pre><code>angular.module("UserShoes").directive("Shoes", ["", function () {
    return {
      ...
  
      controller: function ($scope) {
        // When will $scope.parent.shoes be ready? :-(
      }
      ...
    }
  }]);
  </code></pre>