我们如何在nz-carousel中使用goTo(slidenumber)?如果我想直接查看特定的幻灯片编号

问题描述 投票:0回答:1

请找到ng-zorro链接以供参考。https://ng.ant.design/components/carousel/en#header

typescript carousel angular8 ng-zorro-antd
1个回答
0
投票

使用ViewChild获取组件实例并使用实例方法。

  index = 0;

  @ViewChild(NzCarouselComponent, { static: false }) myCarousel: NzCarouselComponent;

  goTo() {
    this.myCarousel.goTo(Number(this.index));
  }

https://stackblitz.com/edit/angular-6rsuzz?file=src/app/app.component.ts

© www.soinside.com 2019 - 2024. All rights reserved.