Chad Watkins
Chad Watkins

Reputation: 561

AngularJS not returning JSON data from service

I would like this custom service(I know its not the best code) to return this JSON data but nothing is returning no matter what I try. Anyone know what I am doing wrong? I am sure it is something simple that I missed. Here is my code

Upvotes: 0

Views: 84

Answers (1)

AD.Net
AD.Net

Reputation: 13399

It should be in the HTML (just AwesomeCars, not AwesomeCars.carData)

<ul class="list-group" ng-repeat="car in AwesomeCars">

and you need to inject 'carData' in the controller

chadTerm.controller('chad-midterm-controller', ['$scope', 'carData', 
  function($scope, carData) {
        $scope.AwesomeCars = carData.cars;
}]);

updated code

Upvotes: 3

Related Questions