【发布时间】:2017-05-02 16:45:20
【问题描述】:
我一直在努力寻找我做错了什么,也许你可以帮助我。
我正在尝试在 ngb-carousel 模板上使用 *ngFor="let image of card.carouselImgs" 显示轮播,如下所示:
<ngb-carousel>
<template *ngFor="let image of card.carouselImgs" ngbSlide >
<img src="{{image.imgUrl}}" alt="{{image.imgAlt}}">
</template>
</ngb-carousel>
但我收到此错误:
ERROR TypeError: slideArr[0] is undefined
Stack trace:
NgbCarousel.prototype._getNextSlide@http://localhost:4200/vendor.bundle.js:43189:9
NgbCarousel.prototype.cycleToNext@http://localhost:4200/vendor.bundle.js:43149:76
NgbCarousel.prototype._startTimer/this._slideChangeInterval<@http://localhost:4200/vendor.bundle.js:43174:67
ZoneDelegate.prototype.invokeTask@http://localhost:4200/polyfills.bundle.js:3176:17
onInvokeTask@http://localhost:4200/vendor.bundle.js:4326:28
ZoneDelegate.prototype.invokeTask@http://localhost:4200/polyfills.bundle.js:3175:17
Zone.prototype.runTask@http://localhost:4200/polyfills.bundle.js:2943:28
ZoneTask/this.invoke@http://localhost:4200/polyfills.bundle.js:3238:28
timer@http://localhost:4200/polyfills.bundle.js:4433:17
所以我检查了数据是否有问题,但不是,这样做时一切正常:
<div *ngFor="let image of card.carouselImgs">
imgUrl: {{image.imgUrl}}
imgAlt: {{image.imgAlt}}
</div>
输出:
imgUrl: ../../assets/briefcase/1.jpg imgAlt: Hello
imgUrl: ../../assets/briefcase/2.jpg imgAlt: Hello
imgUrl: ../../assets/briefcase/3.jpg imgAlt: Hello
所以我认为是 ngb-carousel 的错误。有什么帮助吗? 在此先感谢:)
【问题讨论】:
标签: twitter-bootstrap angular ng-bootstrap