title: Return object from AngularJS $http get
body: <p>I am using the follow code to get json object and bind it to the $scope</p>
  
  <p><strong>WORKING CODE:</strong></p>
  
  <pre><code>$http({
      url: '/Home/GetJson',
      method: "GET",
      params: {
          clientID: cId
      }
  }).success(function (data) {
      $scope.members = data.members;
  })
  </code></pre>
  
  <p>It works .. what I would like to do is get the results into a <code>var data</code> then add it to the $scope.</p>
  
  <p><strong>FAILING CODE :</strong> </p>
  
  <pre><code>var data = $http({
      url: '/Home/GetJson',
      method: "GET",
      params: {
          clientID: cId
      }
  }).success(function (data) {
      return data.members;
  })
  
  $scope.members = data;
  </code></pre>
  
  <p>When I look at $scope.members, it is empty in the failing code because $scope.members is empty when it is filled (js is event based). </p>
  
  <p>How can I wait till json returns > then var = data > then $scope.members = data ?</p>
  
  <p><strong>WORKING CODE</strong></p>
  
  <p>I used Javascript callback functions as below</p>
  
  <p>Call my main function </p>
  
  <pre><code>DoLogin($scope, $http, email, password, AssingMemberToScope);
  
  
  function DoLogin($scope, $http, email, password, callback) {
  $http({
      url: '/Home/GetJson',
      method: "GET",
      params: {
          clientID: cId
      }
  }).success(function (data) {
      callback($scope, data);   //&lt;----- Call Back occurs
  })
  }
  </code></pre>
  
  <p>//--Call-back Function working and code is separated --/</p>
  
  <pre><code>function AssingMemberToScope($scope, data) {
      if (data.msg) {
          $('.loading').hide();
          $scope.member = data.member;
      } else {
          $('.loading').hide();
          $('#msg').show();
      }
  
  }
  </code></pre>