0

Here is my controller, being served from localhost port 80:

function ListCtrl($scope, $http) {
    $http.get('/api/moz').success(function (data) {
        $scope.moz = data;
    });
}

And the output from 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 the output from {{moz}} is [].

Been working on this for many hours now, and have no clue how to get it to work. My scaffold is identical to step5 of the angularjs tutorial.

user2283066
  • 141
  • 1
  • 2
  • 6

2 Answers2

0

You're retrieving an array, and need to iterate over it. Try this in your template:

<ul>
 <li ng-repeat="m in moz">{{m.sName}}</li>
</ul>
Mike Robinson
  • 24,971
  • 8
  • 61
  • 83
0

Looks like the only status-code supported by the success promise function is 200.

So going against the standard I have made all my "successful" returns HEAD 200.

It is now working.

user2283066
  • 141
  • 1
  • 2
  • 6