Reputation: 608
I am using @ngx-gallery/lightbox
to display an image gallery. But it does not display any images. This I provide some code and Stackblitz demo as your reference
HTML
<button mat-button (click)="lightbox.open(0, 'lightbox')">Open Gallery</button>
Component
items: GalleryItem[];
constructor(public gallery: Gallery, public lightbox: Lightbox) {
}
ngOnInit() {
// This is for Basic example
this.items = imageData.map(item => {
return new ImageItem(item.srcUrl, item.previewUrl);
});
// This is for Lightbox example
this.gallery.ref('lightbox').load(this.items);
}
}
Upvotes: 1
Views: 2024
Reputation: 696
Seems like you have not initialised ImageItem properly, try this
this.items = imageData.map(item => new ImageItem({ src: item.srcUrl, thumb: item.previewUrl }));
instead of
this.items = imageData.map(item => {
return new ImageItem(item.srcUrl, item.previewUrl);
});
Upvotes: 3
Reputation: 1177
The issue is that the ImageItem
class expects a single parameter in form of an object.
This should fix your issue:
this.items = imageData.map(item => {
return new ImageItem({ src: item.srcUrl, thumb: item.previewUrl });
});
Upvotes: 3
Reputation: 11478
I'm not sure what api u were reading from, but according to their official api, this demo should work
Upvotes: 0