AngularJS Promise : $http GET example

A simple example using $http.get() to discover its promises and theirs specific functions like success() or error()

by brandon_rmsy

HTML

<div ng-app>
  <div ng-controller="PromiseCtrl">
      <h2>$http.get()</h2>
      <h3>Insights IDs</h3>
      <p>{{ids}}</p>
  </div>
</div>

JavaScript

function PromiseCtrl($scope, $http) {

    $http.get('http://classifinity.com/api/insights/df?key=*&num=500').then(function(value) {
        //$scope.example2 = value.data.response.docs;
        var data = value.data.response.docs   
				for (var i = 0; i < data.length; i++) {
   				 $scope.ids += "\n" + (data[i].id);
				}

    });
    
}