I'm trying to fetch an image from an API using AngularJS.
I'm using a link to trigger the $http function, and trying to parse the image url from the JSON response back into the HTML, but I think I'm missing something, as the response comes back OK, but the img url doesn't get "in place".
Here's my html:
<a ng-click="getImages()">Image: <img src="{{album.image.2.#text}}" /></a>
My JS:
$scope.getImages = function () {
$http.get('http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=%%%&artist=vnv+nation&album=empires&format=json').
success(function(data4) {
$scope.images = data4;
});
}
And a example of JSON response:
album: {name:Empires, artist:VNV Nation, id:2025273, mbid:0c3ccb9f-e6c4-419d-934e-02e3be8a08c9,…}
artist: "VNV Nation"
id: "2025273"
image: [{#text:http://userserve-ak.last.fm/serve/34s/93873429.png, size:small},…]
0: {#text:http://userserve-ak.last.fm/serve/34s/93873429.png, size:small}
1: {#text:http://userserve-ak.last.fm/serve/64s/93873429.png, size:medium}
2: {#text:http://userserve-ak.last.fm/serve/174s/93873429.png, size:large}
#text: "http://userserve-ak.last.fm/serve/174s/93873429.png"
size: "large"
EDIT: I made a Plunker. You can see in the console how the json response is called correctly, but the image url is still not being shown.