I'm using Rest to display information from my database in Json format on my localhsost. The url is http://localhost:8080/restful-services/api/getAllHorses.
I'm new to Angular and what I'm looking to do is use a http get to access the json information.
This is my json
[{"horse":{"age":"6yo","breeder":"David Harvey","countryBred":"(IRE)","horseAge":"6yo","horseId":1,"horseName":"Brain Power","owner":"Michael Buckley","pedigree":"Kalanisi","sex":"(08May11 b g)","trainer":{"days":9,"location":"Lambourn","seaonWinners":119,"seasonStrikeRate":27,"stake":-69.77,"trainerId":2,"trainerName":"Nicky Henderson"},"trainerName":"Nicky Henderson"}},
This is what I've tried with the Angular but it is not displaying anything. Any help is much appreciated, thanks.
var horseApp = angular.module('horseApp', []);
horseApp.controller('HorseCtrl', function ($scope, $http){
$http.get('http://localhost:8080/restful-services/api/getAllHorses').success(function(data) {
$scope.horse = data;
});
});
<body ng-controller="HorseCtrl">
<h2>Horses</h2>
<table>
<tr>
<th>Age</th>
<th>Name</th>
<th>Breeder</th>
</tr>
<tr ng-repeat="age in Horse.age ">
<td>{{horse.age}}</td>
<td>{{horse.horesName}}</td>
<td>{{horse.breeder}}</td>
</tr>
</table>
</body>