title: Assigning Angular $http.get call object to variable
body: <p>Okay so, first of all, I'm pretty new Angular. I'm trying to get all of my documents (a JSON object) from CouchDB using a $http.get call. The JSON object is basically a list of people, with an id, their names and some quotes:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{
  
      "total_rows": 2,
      "offset": 0,
      "rows": [
          {
              "id": "5",
              "key": "5",
              "value": {
                  "rev": "1-b26014051b18bce04ae2190d9cb92d81"
              },
              "doc": {
                  "_id": "5",
                  "_rev": "1-b26014051b18bce04ae2190d9cb92d81",
                  "dataid": "5",
                  "dataname": "Robin",
                  "dataquote": "Blah"
              }
          },
          {
              "id": "9",
              "key": "9",
              "value": {
                  "rev": "1-8ecbf37d0ccc129530e57747b46faa8e"
              },
              "doc": {
                  "_id": "9",
                  "_rev": "1-8ecbf37d0ccc129530e57747b46faa8e",
                  "dataid": "9",
                  "dataname": "Bert",
                  "dataquote": "Hallo"
              }
          }
      ]
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'd like to show the name of each person according to the following HTML:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
      &lt;p class="lead"&gt;Persons&lt;/p&gt;
      &lt;ul&gt;
          &lt;li ng-repeat="p in persons"&gt;&lt;a ng-href="#/quotes/{{ p.doc.dataid }}"&gt;{{ p.doc.dataname }}&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And here is the controller and service I'm using:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>.controller('personsCtrl', ['$scope', 'personSrv', function personsCtrl($scope, personSrv) {
    $scope.persons = personSrv.getAllpersons();
  
  .factory('personSrv', ['$http', '$q', function ($http, $q) {
  
    return{
      getAllpersons: function(){
  
      return $http.get('http://localhost:5984/quotes/_all_docs?include_docs=true')
        .then(function(response){
          if (typeof response.data === 'object'){
            return response.data.rows;
          } else{
            return $q.reject(response.data);
          }
  
        }, function(response){
          return $q.reject(response.data);
        });
      }
    };
  }])</code></pre>
  </div>
  </div>
  </p>
  
  <p>I checked my debugger and the GET call works fine, but the problem is that the names won't show up on the page in my browser. I'm assuming the data that's been returned doesn't get assigned to the $scope.persons var properly.</p>