title: AngularJS, $http.get() and "controller as"
body: <p>I'm pretty new to the whole AngularJS world and how it works, however I am struggling to get it working as expected. I know that its something to do with the way I am using <code>$http.get()</code> and trying to assign the variables back to my controller, but I just can't figure it out.</p>
  
  <p>Using <code>$scope</code> instead of <code>this</code> I can get it working, however if possible, I'd prefer to be using <code>this</code> so I can use "controller as"</p>
  
  <p>Code:</p>
  
  <pre><code>app.controller('ctrlSuppliers', function($http){
  
      this.supplierList = {};
  
      $http.get("http://some_url_here")
              .success(function(response) {  this.supplierList = response.records;})
              .error(function() { this.supplierList = [{supplier_id: 0, supplier_name: 'Error Getting  Details'}];});
  });
  </code></pre>
  
  <p>From this example, I cannot then access any results from the <code>$http.get</code> request from within the <code>supplierList</code> within the HTML page (i.e. <code>{{ supplier.supplierList[0].supplier_name }}</code> doesnt display any results)</p>
  
  <p>I know that if I change the controller to <code>$scope</code> I can get access to that data (although not using the same format as above), and I also know the data is being populated by using <code>console.log(this.supplierList)</code> inside the <code>.success</code> call.</p>
  
  <p>I also know that the reason its not working is because the context of <code>this</code> changes from within the controller to within the <code>$http.get</code> call.</p>
  
  <p>So my question is this: How do you get access to the results from a $http.xxx call using <code>this</code> instead of <code>scope</code>? I have read a few different sources on it, but most talk about using <code>$scope</code> and promises. I've not found any that cover using <code>this</code> (or declaring it with <code>var supplier = this</code>). Any help would be much appreciated.</p>
  
  <p>Thanks,</p>