When I use the command console.log($scope.data)
, I am able to view my JSON file. Additionally, by using
<div ng-repeat="item in data">
, I can see all the items in the view. However, when I try console.log($scope.data[0])
or console.log($scope.data[0].name)
, I get an error stating "undefined". Similarly, console.log($scope.data.length)
returns 0. How do I access the items in the controller?
Edit:
$scope.data
contains a JSON file retrieved using $scope.data = service.query();
. The structure of the json file is as follows:
I am confused as to why the length is returning 0 even though ng-repeat is functioning properly.