ngGallery
ngGallery copied to clipboard
how to resolve a error Cannot read property '0' of undefined
GalleryCtrl.js : angular.module('myApp').controller('GalleryCtrl',[function($scope,$document){ var self = this;
self.images = [
{thumb: 'image/slider/1.jpg', img: 'image/slider/1.jpg', description: 'Image 1'},
{thumb: 'image/slider/2.jpg', img: 'image/slider/2.jpg', description: 'Image 2'},
{thumb: 'image/slider/3.jpg', img: 'image/slider/3.jpg', description: 'Image 3'},
{thumb: 'image/slider/4.jpg', img: 'image/slider/4.jpg', description: 'Image 4'}
];
}]);
Gallery.html :
and i add 'jkuri.gallery' in app.js file but i have e error :
TypeError: Cannot read property '0' of undefined
at Scope.scope.getImageDownloadSrc (ngGallery.js:129)
at fn (eval at
please help me
I had the same issue in a Ruby on Rails application where I needed to use ngGallery. I was using Restangular to set an empty array of images then update it when the promise resolved. My solution was to use an ng-if in the view:
<ng-gallery images="ctrl.images" ng-if="ctrl.images.length"></ng-gallery>
Let me know if that works,
@tomchinery This worked well. Thanks!