title: functions executed before angular http success response
body: <p>Am trying to hit web service with a directive controller, I hit the post method and got the response, but values I expected are become empty because all compiled before the success response.
  This is my controller within the directive</p>
  
  <pre><code>controller: ['$scope', '$http', 'popupService','SessionUtils', function($scope, $http, popupService,SessionUtils) {
                  $scope.responseValue = "";
                    $scope.sendCSVFile = function(link, fileData) {
                      $scope.seriveResponse = $http({
                        method: "POST",
                        url: link,
                        data: fileData,
                        headers: {
                          'Content-Type': undefined
                        }
                      }).success(function(response) {
                          if(response.status == "FAILURE"){
                              popupService.showErrMsg(response.message);
                              return false;
                          }
                          else {
                              $scope.responseValue = response;
                              //SessionUtils.updateResponse(response);
                              var success = "File Uploaded Successfully";
                              popupService.showSuccessMsg(success);
                              return response;
                          }
                          return $scope.responseValue = response;
                      });
  
                      });
  </code></pre>
  
  <p>and I called the controller from the directive link function like </p>
  
  <pre><code>var res = scope.sendCSVFile(attrs.getUrlModel, formData); 
  scope.gridUpdate(res);
  </code></pre>
  
  <p>the value <code>res</code> returning undefined, but I get the response after I binded the <code>res</code>. How to I get the promising response and execute the function after.!</p>