【问题标题】:ngx-gallery: How to get active image?ngx-gallery:如何获取活动图像?
【发布时间】:2020-05-12 11:00:09
【问题描述】:

在文档中,只有为滑块的活动缩略图添加样式。但是如何从活动图像中获取数据绑定?

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

【问题讨论】:

    标签: angular typescript gallery image-gallery


    【解决方案1】:

    你可以通过获取组件实例来获取活动/选定索引,示例如下所示

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

    您可以使用 selectedIndex 获取活动项目/数据this.galleryImages[this.ngxGalleryComponent.selectedIndex]
    希望这会有所帮助:)

    【讨论】:

      猜你喜欢
      • 2019-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 2018-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多