Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
1  
Seems to be something to do with the status code... :\ –  user2283066 May 21 '13 at 14:05
 
302 Found is a redirect. You should find out why that isn't a 200. –  jessegavin May 21 '13 at 14:23
add comment

2 Answers

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>
share|improve this answer
 
Still getting no content (blank screen... 'Inspect element' shows: <ul><!-- ngRepeat: m in phones --></ul> there. –  user2283066 May 21 '13 at 13:57
 
@user2283066 Why are you doing m in phones? Phones isn't bound to your scope, "moz" is. –  Mike Robinson May 21 '13 at 15:05
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.