title: Problems parsing a JSON response using AngularJS
body: <p>I am new using AngularJS and I am having an issue parsing a json response. This is the HTML code I am using:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app&gt;
  &lt;head&gt;
      &lt;script src="@routes.Assets.at("javascripts/angular.min.js")" type="text/javascript"&lt;/script&gt;
      &lt;script src="@routes.Assets.at("javascripts/carLibrary.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div ng-controller="CarCtrl"&gt;
      &lt;ul&gt;
          &lt;li ng-repeat="car in cars"&gt;
              {{car.name}}
              &lt;p&gt;{{car.speed}}&lt;/p&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
      &lt;hr&gt;
      &lt;p&gt;{{response}}&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is the Javascript code using AngularJS:</p>
  
  <pre><code>function CarCtrl($scope, $http) {
  
      $scope.getAllCars = function () {
          $scope.url = 'getAllCars';
  
          $http.get($scope.url).success(function (data, status) {
              $scope.response = data;
              var carsFromServer = JSON.parse(data);
              $scope.cars = carsFromServer.allCars;
          }).error(function (data, status) {
                  $scope.response = 'Request failed';
              });
      }
  
      $scope.getAllCars();
  }
  </code></pre>
  
  <p>The HTML is showing the variable $scope.response with the JSON returned by the server, but it is not showing anything in the list at the top. The JSON is perfectly formatted, however $scope.cars variable seems to be always empty.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Many thanks,</p>
  
  <p>GA</p>