As a beginner in the world of AngularJS and JSON, I decided to test my skills with the following example. However, I am encountering some difficulty loading data from a JSON file:
<body>
<h2>AngularJS Sample Application</h2>
<div ng-app="" ng-controller="kittyController">
<table>
<tr>
<th>Name</th>
<th>Roll No</th>
<th>Percentage</th>
</tr>
<tr ng-repeat="kitty in kitties">
<td>{{ kitty.Name}}</td>
<td>{{ kitty.RollNo}}</td>
<td>{{ kitty.Percentage.num}} -- {{kitty.Percentage.avrg}}</td>
</tr>
</table>
</div>
<script>
function kittyController($scope, $http) {
var url = "data.json";
$http.get(url).success(function(response) {
$scope.kitties = response;
});
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"> </script>
</body>
data.json
[
{
"Name" : "kitty 1",
"RollNo": 101,
"Percentage" : [
{"num" : 88,
"avrg": 4 }
]
},
{
"Name" : "Kitty 2",
"RollNo": 102,
"Percentage" : [
{"num" : 68,
"avrg": 4 }
]
}
]
Although I can view the Name and Roll number, I'm unable to see the values for percentage.num and percentage.avg. Is there something crucial that I might be overlooking?