0

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

2
  • Doesn't the factory have to be defined before the Controller? Commented Mar 14, 2014 at 16:02
  • AD.Net's answer is correct. You only had those two errors. You ought to look up Dependency Injection, to better understand why you shouldn't reference carData in your HTML. docs.angularjs.org/guide/di Commented Mar 14, 2014 at 16:07

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.