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.

I'm trying to show some images whose urls I get as a json response from a server. Using examples such as this and that was useful, but I can't seem to get it to work. I think the reason might be that the above examples parse simple json objects, while the response I'm trying to is more complex. I have tried unsuccessfully to handle that with the ng-repeater and ng-src directives, and also using this example.

This not an http problem (status is 200) or a json source problem(I have checked the response with Jsonlint and it's ok).

my script:

            $http.get(path)
                .then(function(res) {
                    console.log("$http succeeded");
                    $scope.thumbList = res.data;
            });

my html:

    <div>
        <ul ng-repeat="item in thumbList.response.resultset.items" >
            <li>
                 <img ng-src="{{item.images.0.thumb_uri}}">
            </li>
        </ul>

    </div>
share|improve this question
    
Looks good, what does the http response json object look like? –  Zack Argyle Mar 19 '14 at 1:47
    
{response:{resultset:{items:[{images:{0:{thumb_uri:"http..."}}}]}}} –  Kepedizer Mar 19 '14 at 1:59
    
change the 0 into some words. angular have a parser that parse your expression. they not simply use eval. "item.images.0.thumb_uri" is syntactically does not mean it is right to use integer as key. –  wayne Mar 19 '14 at 2:20
    
wayne problem is I am not the maker of the json, only trying to parse it. –  Kepedizer Mar 19 '14 at 2:39
    
try assigning $scope.thumbList = res.data.response.resultset.items; and please notify if it works –  Rishul Matta Mar 19 '14 at 4:14

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.