我想通过ngFor在转盘滑块中显示数据。但它似乎不起作用。此代码运行良好
<owl-carousel carouselClasses="inner-carousel owl-simple rows cols-1" [options]="introSlider">
<div class="intro-slide" style="background-image: url({{storeBannerUrls[0]}}); background-size: 100% 100%;"></div>
<div class="intro-slide" style="background-image: url({{storeBannerUrls[1]}}); background-size: 100% 100%;"></div>
</owl-carousel>
但我想通过循环设置url。像
*ngFor="let url of storeBannerUrls"
提前谢谢。
确保将整个divs
部分包装成ng-template
,然后需要包含这样的carouselSlide
。
<owl-carousel carouselClasses="inner-carousel owl-simple rows cols-1" [options]="introSlider">
<ng-template carouselSlide>
<div class="intro-slide" style="background-image: url({{storeBannerUrls[0]}}); background-size: 100% 100%;"></div>
<div class="intro-slide" style="background-image: url({{storeBannerUrls[1]}}); background-size: 100% 100%;"></div>
</ng-template>
</owl-carousel>