ngx-gallery:如何获取活动图像?

ngx-gallery: How to get active image?

在文档中,仅向滑块的活动缩略图添加了样式。但是如何获取活动图像绑定的数据呢?

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

可以通过获取组件实例获取active/selected索引,示例如下

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

您可以使用 selectedIndex 激活 item/data this.galleryImages[this.ngxGalleryComponent.selectedIndex]
希望这有帮助:)