I am trying to show the data coming from a server, I tried to make a controller and copy the response to a property of scope. I tried 'response' and 'response.data' and none of them worked.
the html file looks like this:
<!DOCTYPE html>
<html>
<head>
<script src="angular.min.js"></script>
<title>Service Call ...</title>
</head>
<body>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("https://linkToServer.json")
.success(function(response) {$scope.trainings = response.data;
});
});
</script>
<div ng-app="myApp" ng-controller="customersCtrl">
<ul>
<li ng-repeat="tr in trainings">
{{ tr.id }}
</li>
</ul>
</div>
</body>
</html>
The json structure is something like:
[
{
"id" : "sm1001",
"name" : "Lu",
},
{
"id" : "lm9898",
"name" : "Di",
},
....
]
What is wrong?
Plunkr of the problem
.success(function(response) {$scope.trainings = response;
? – Vineet Aug 6 '15 at 20:22https
. Is your script too? – Boaz Aug 6 '15 at 20:24