私はウェブサイトにカルーセルを表示するためにブートストラップを使用していますが、this exampleに続いてスライドごとにいくつかのアイテムを表示します。静的画像を使用すると完全にうまく動作します(例:this jsFiddle、の例では、後でを処理するために、表示フレームがboostrapのメディアクエリによる不思議な効果を避けるのに十分な大きさであることを確認してください)。1つのスライドに複数のアイテムがあるブートストラップカルーセルとAngularJS
しかし、私は変数からカルーセルのコンテンツを定義し、ng-repeat
でAngularJSでバインドしたいと思います。そこに問題が発生します。データは正しくバインドされていますが、「アクティブ」項目と見なされる画像のみが表示されます。それは理にかなっていることを理解していますが、静的に定義された画像ではそのように振る舞いませんでした。私のバグを見るにはthis jsFiddleを参照してください。
- 表示し、すべての項目と設定オーバーフロー:隠された
- 変更アイテムが33%にサイズ、すべてを表示する代わりに、クラスCOL-MD-4 を使用しての私がこれまで試したどのような
HTML
<div class="carousel-started-themes" style="height:150px; width:700px;">
<div class="carousel slide" id="myCarousel">
<div class="carousel-inner">
<div class="item" ng-class="{active:!$index}" ng-repeat="img in image">
<div class="col-md-4"><a href="#"><img ng-src="{{img}}" class="img-responsive"></a>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev" style="z-index:10000;"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next" style="z-index:10000;"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
JS
function MyCtrl($scope) {
$scope.image =["https://wallpaperscraft.com/image/minimalism_sky_clouds_sun_mountains_lake_landscape_95458_1600x900.jpg", "https://wallpaperscraft.com/image/clouds_milky_way_eclipse_light_68883_1600x900.jpg", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSl5bsNT-Qtm0tfbydXFMuFCG27Kug6D5Z3hrgitIQqQq22Da95Ig", "https://wallpaper.wiki/wp-content/uploads/2017/05/Photos-1600x900-Wallpapers-HD.jpg", "https://wallpaperscraft.com/image/torzhok_tver_region_evening_sunset_river_reflection_autumn_russia_58028_1600x900.jpg", "https://wallpaper.wiki/wp-content/uploads/2017/04/wallpaper.wiki-1600x900-HD-Image-PIC-WPD0014727.jpg"];
}
$('#myCarousel').carousel({
interval: false
});
$('.carousel .item').each(function() {
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length > 0) {
next.next().children(':first-child').clone().appendTo($(this));
} else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
私はあなたが何を意味するか理解していません、私は何も表示したり隠したりしないので、アイテムのアクティブな状態はBootstrapのカルーセルに固有のものです。私は手動ですべての表示とオーバーフローを試みた:隠された;残念ながら、その行動はほぼ同じでした。 – Driblou