Here are the codes that I've written:
DRF Page [ http://localhost:8000/index/info/?format=json ]
[{"id": 1, "name": "Michel", "city": "Florida", "country": "United States"}, {"id": 2, "name": "Shuvo", "city": "London", "country": "United Kingdom"}]
2.html [this is my second attempt]
<!DOCTYPE html>
<html>
<script src="angular.min.js"></script>
<script src="2.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="x in info">
{{ x.name + ', ' + x.country }}
</li>
</ul>
</div>
</body>
</html>
2.js
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("http://localhost:8000/index/info/?format=json")
.success(function(response) {
$scope.info = response;
});
});
My 2.html page shows NOTHING. It's completely blank. What am I doing wrong? :(
I suspect it's something to do with the format of the data being returned in
What are you seeing in the console when http.get runs?
Here's a plunkr showing it working with your data
http://plnkr.co/edit/x0OtVbsnSMk3mdhRFEkc
since django and angular use the same notation to display variables, you will have to use the verbatim tags for using
{{}}
as angular tags. Otherwise they will be treated as django tags.