Char
Char

Reputation: 2133

ngx-gallery: How to get active image?

In the documentation, there is only adding of style to the active thumbnail of the slider. But how do you get the data bound from the active image?

https://github.com/lukasz-galka/ngx-gallery

Upvotes: 1

Views: 2791

Answers (1)

Sameer
Sameer

Reputation: 5188

You can get active/selected index by getting component instance, Example shown below

import { NgxGalleryComponent } from "ngx-gallery";
...
@ViewChild(NgxGalleryComponent) ngxGalleryComponent;
...
ngOnInit() {
 console.log(this.ngxGalleryComponent.selectedIndex);
}

You can use selectedIndex to get active item/data this.galleryImages[this.ngxGalleryComponent.selectedIndex]
Hope this helps :)

Upvotes: 2

Related Questions