title: Async call back fires after method return (angularjs .then())
body: <p>I have the following code: (I've tried many ways)</p>
  
  <pre><code>performLogin = (data: LoginRequest) =&gt; {
    var deferred = this.qService.defer();
    var response = this.httpService.get(
    myServiceURL + '&amp;' + ObjecttoParams(data))
    .then(function (response) {
      debugger;
      this.loginResponse = JSON.parse(JSON.stringify(response.data));
    });
    debugger;
    deferred.resolve(response);
    debugger;
    return(this.loginResponse);
  }
  </code></pre>
  
  <p>This is my constructor for this service:</p>
  
  <pre><code>  constructor($http: ng.IHttpService, $location: ng.ILocationService, $q: ng.IQService) {
              this.qService = $q;
              this.httpService = $http;
              this.locationService = $location;
              this.loginResponse = new LoginResponse();
              this.serviceURL = staticURL + currentServiceName;
  
          }
  </code></pre>
  
  <p>I'm calling to performLogin in my controller, who expect to receive a "LoginResponse" class, but because the .then() is happening later, my "return this.loginResponse) happens before the .then() is even called.</p>
  
  <p>How to I make him wait for the .then() to complete before returning?</p>