0

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>
6
  • Looks good, what does the http response json object look like? Commented Mar 19, 2014 at 1:47
  • {response:{resultset:{items:[{images:{0:{thumb_uri:"http..."}}}]}}} Commented Mar 19, 2014 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. Commented Mar 19, 2014 at 2:20
  • wayne problem is I am not the maker of the json, only trying to parse it. Commented Mar 19, 2014 at 2:39
  • try assigning $scope.thumbList = res.data.response.resultset.items; and please notify if it works Commented Mar 19, 2014 at 4:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.