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 am trying to fetch an image from a json API using angularjs. I am using a html file for fetching the image,but i think i am missing something,it doesn't work. Here's my html:

<li ng-repeat="post in posts">
  <a ng-click="clickToOpen({{post.id}})">{{post.title}}</a><p> img src="{{post.attachments.url}}"></p>      
</li>

And my JSON:

"attachments": [
            {
               "id": 15534,
               "url": "http://www.grandlakebusinessjournal.com/wp-content/uploads/2013/02/Tera-Mirand-Shores-Platt-Phanse-One2.jpg",
               "slug": "tera-mirand-shores-platt-phanse-one-3",
               "title": "Tera Mirand Shores Platt Phanse One",
               "description": "",
               "caption": "",
               "parent": 15455,
               "mime_type": "image/jpeg",
               "images": []
            }

         ]
share|improve this question
add comment

1 Answer

Use ng-src and be careful about your img tag, it does miss a < at the beginning

<img ng-src="{{post.attachments.url}}" />
share|improve this answer
    
I tried with ng-src,but not working –  user3584779 Apr 29 at 11:31
    
when you check it in inspect element.. do you bind the url in ng-src? –  Yagiz Ozturk Apr 29 at 11:32
    
i didn't understand –  user3584779 Apr 29 at 11:40
    
on chrome inspect element, can you see the binded URL in html correctly? –  Yagiz Ozturk Apr 29 at 11:44
    
i have seen only <img ng-src>,not the url –  user3584779 Apr 29 at 11:49
show 3 more comments

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.