title: angularjs callback / wait for function to finish
body: <p>I'm i bit stuck with function which is assigned to the <code>$scope variable</code>.
  need to wait until it's finished.</p>
  
  <p>This is the <strong>function</strong> assigned to <code>$scope variable</code>:</p>
  
  <pre><code>$scope.ChooseHome = function() {
      ModalWindowService.openChooseHomeDialog($scope);
  }
  </code></pre>
  
  <p>in ModalWindowService I have:</p>
  
  <pre><code>function openChooseHomeDialog($scope) {
      $scope.animationsEnabled = true;
  
      var modalInstance = $modal.open({
          animation: $scope.animationsEnabled,
          templateUrl: '/view/user/ChooseHomeDialog.html',
          controller: 'chooseHomeDialogController',
          windowClass: 'detail-modal-window'
      });
      modalInstance.result.then(function (CondoID) {
          $scope.choosenCondoID = CondoID;
      });
  }
  </code></pre>
  
  <p>what I want to do is properly receive this variable '$scope.choosenCondoID' after I get it from modal in '$scope.ChooseHome' function and do some work with it.</p>
  
  <p>smth like this options:</p>
  
  <pre><code>$scope.ChooseHome = function() {
      ModalWindowService.openChooseHomeDialog($scope).then(*do my stuff*); /
      ModalWindowService.openChooseHomeDialog($scope).success(*do my stuff*);
  }
  </code></pre>
  
  <p>But it's not working, I'm getting errors like this:</p>
  
  <pre><code>'TypeError: (intermediate value).success is not a function'
  </code></pre>