javascript - HTTP GET not working in AngularJS? -
here controller, being served localhost port 80:
function listctrl($scope, $http) { $http.get('/api/moz').success(function (data) { $scope.moz = data; }); }
and output curl:
curl -i localhost/api/moz http/1.0 302 found date: tue, 21 may 2013 13:35:43 gmt server: wsgiserver/0.1 python/2.7.4 content-type: application/json [{"sid": 0, "sname": "sa"},{"sid": 0, "sname": "ab"},{"sid": 0, "sname": "ds a"}]
unfortunately output {{moz}}
[]
.
been working on many hours now, , have no clue how work. scaffold identical step5 of angularjs tutorial.
you're retrieving array, , need iterate on it. try in template:
<ul> <li ng-repeat="m in moz">{{m.sname}}</li> </ul>
Comments
Post a Comment