Angular NgbCarousel select不切换幻灯片

Angular NgbCarousel select不切换幻灯片,angular,ng-bootstrap,Angular,Ng Bootstrap,我正在尝试创建一个缩略图行来切换旋转木马的幻灯片 click事件正在工作,转盘位置正确-我在NgbCarousel代码中放置了一些断点,传递的幻灯片id是正确的,直到切换幻灯片为止。但是,滑动切换没有发生 转盘本身工作正常-箭头和指示器都正常 角度6.1.0 Ng bootstrap 3.2.0 更新 它在重新安装节点模块后开始工作。虽然它非常滞后(img交换机10秒,没有额外的网络请求),但情况不同 模板: <div class="thumbs mx-auto"> <ul

我正在尝试创建一个缩略图行来切换旋转木马的幻灯片

click事件正在工作,转盘位置正确-我在NgbCarousel代码中放置了一些断点,传递的幻灯片id是正确的,直到切换幻灯片为止。但是,滑动切换没有发生

转盘本身工作正常-箭头和指示器都正常

角度6.1.0 Ng bootstrap 3.2.0

更新 它在重新安装节点模块后开始工作。虽然它非常滞后(img交换机10秒,没有额外的网络请求),但情况不同

模板:

<div class="thumbs mx-auto">
  <ul *ngIf="pics">
    <li *ngFor="let pic of pics" (click)="switchPic(pic)">
      <figure>
        <img src="{{ getIconUrl(pic) }}">
      </figure>
    </li>
  </ul>
</div>
<ngb-carousel #clotheCarousel="ngbCarousel" *ngIf="pics"
  showNavigationArrows="true"
  showNavigationIndicators="true"
  interval="0">
  <ng-template ngbSlide *ngFor="let pic of pics" id="{{ stripSlash(pic.public_id) }}">
    <figure>
      <img src="{{ getThumbUrl(pic) }}" alt="Pic">
    </figure>
  </ng-template>
</ngb-carousel> 

我不确定你的ViewChild(NgbCarousel)。你确定你的console.log(this.carousel)显示了旋转木马吗?顺便说一下,您可以在函数中使用引用变量

<!--pass "clotheCarousel" in the function-->
<li *ngFor="let pic of pics" (click)="switchPic(clotheCarousel,pic)">
尝试更改:

@ViewChild(NgbCarousel) carousel: NgbCarousel;
致:

和使用(但可能需要索引id):

而不是:

this.carousel.select(this.stripSlash(pic.public_id));
以及:

<ng-template ngbSlide *ngFor="let pic of pics" id=" stripSlash(pic.public_id)">

这有点棘手,选择器是“ngb-slide-X”,X的当前索引是0

假设您有一个表,当您单击一行时,您希望更新一张图片

@ViewChild(NgbCarousel,{static:true})旋转木马:NgbCarousel;
...
单击(id:编号,i:编号){
此.carousel.select('ngb-slide-'+i);
}

{{i+1}}
{{signature.date}日期:'shortDate'}
{{signature.client}}
{{签名.司机}
{{signature.signataire}
.....
{{signature.caption}


谢谢您的回复。ViewChild返回正确的旋转木马-它具有我放在那里的确切元素。但是,当我按照您的建议执行操作时,我发现
无法读取未定义的属性“select”
error在开始时仅放置一个*ngIf=“pics”或您的.html-不是一个用于carousel,另一个用于ul,这是完全合理的谢谢!但是没有任何更改,它仍然不会切换。顺便说一句,如果ngb-slide-X不适合,您可以指定id。。。。再见,谢谢你抽出时间,文森特,但这对我来说并不及时。也许我稍后会回来。解决方案就在select函数中,正如@VincentGODIN提到的:this.carousel.select('ngb-slide-'+I);
@ViewChild("clotheCarousel") carousel: NgbCarousel;
this.carousel.activeId = this.stripSlash(pic.public_id);
this.carousel.select(this.stripSlash(pic.public_id));
<ng-template ngbSlide *ngFor="let pic of pics" id=" stripSlash(pic.public_id)">