I'm trying to create an ionic application which uses a gallery. I'm unsure why my image isn't being loaded into the application.
What i'm trying to develop is an gallery which loads the images from a JSON file.
Here's my HTML
<ion-view view-title="Gallery" align-title="center">
<ion-content ng-controller="photoCtrl" ng-init="getImages()">
<div class="row" ng-repeat="image in images" ng-if="$index % 4 === 0">
<div class="col col-25" ng-if="$index < images.length">
<img ng-src="{{data.images[$index].src}}" width="100%" />
</div>
<div class="col col-25" ng-if="$index + 1 < images.length">
<img ng-src="{{data.images[$index + 1].src}}" width="100%" />
</div>
<div class="col col-25" ng-if="$index + 2 < images.length">
<img ng-src="{{data.images[$index + 2].src}}" width="100%" />
</div>
<div class="col col-25" ng-if="$index + 3 < images.length">
<img ng-src="{{data.images[$index + 3].src}}" width="100%" />
</div>
</div>
</ion-content>
</ion-view>
Javascript:
.controller("photoCtrl", function($scope, $http) {
$scope.images = [];
$scope.getImages = function() {
$http.get('https://api.myjson.com/bins/30vuu')
.success(function(data) {
$scope.data = images;
})
}
});
I have also created a codepen: http://codepen.io/beefman/pen/eNMgzG
images
that contains a string. Also in your$http
callback you aren't doing anything with the responsedata
so you are assigning$scope.data
to empty array