I am newbie to angular.js. I am developing a shoppingcart Application, I am getting a JSON Object from database from AJAX call. But I am not getting How to show all the images(url stored in fileLocation in JSON) from JSON response on to Html page using Angular js.
Here is my code:
My JSON
{
"_embedded": {
"binaries": [
{
"fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
"username": "testuser3",
"description": "The company required the 28-year-old's help on a matter the directors felt could affect the share price: its Wikipedia page. Short, uninteresting ."
},
{
"fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
"username": "Sumanth",
"description": "Sample"
},
{
"fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
"username": "as",
"description": "as"
}
]
}
}
JSON is assigned to variable data
My Angularjs Controller:
myAppDirectives.
controller('MainCtrl', function ($scope,$http,dateFilter) {
$http({ method: 'GET', url: 'http://localhost:8087/sportsrest/binaries/' }).success(function (data) {
var result = data;
var json=JSON.stringify(result);
var data = JSON.parse(json);
$scope.cart = data; // response data
}).
error(function (data) {
alert("error" + data);
console.log(data);
});
});
My HTML page:
<html lang="en" ng-app="myApp" id="ng-app">
<body ng-controller="MainCtrl">
<article class="main-content" role="main">
<section class="row">
<div class="content">
<div class="bookmarks-list">
<ul>
<li ng-repeat="data">
<h3>{{cart._embedded.binaries.username}}</h3>
<img ng-src="{{cart._embedded.binaries.fileLocation}}"/>
</li>
</ul>
</div>
</div>
</section>
</article>
</body>
</html>
Can Anyone please help me How to iterate through All the images on JSON object and show on HTML page.
Thanks in Advance.