【发布时间】:2018-08-22 14:45:11
【问题描述】:
我有一个使用带有 ng-repeat 的引导轮播的 div。我还有一种方法可以将项目添加到当前项目列表中。
因此,如果我在索引 0 中并单击添加按钮,我希望能够滑动到新项目。
目前我所拥有的,索引似乎设置正确,但它没有滑到新项目
$scope.items.splice($scope.currentIndex+1, 0, newItem);
$scope.currentIndex = $scope.currentIndex+1;
$('#myCarousel').carousel($scope.currentIndex);
它仍然只显示第 1 项的数据。但是当我尝试单击下一步时,它会移动到该新项目。
我也用$('#myCarousel').carousel('next'); 尝试过,结果是一样的
编辑:
<div id="myCarousel" class="carousel slide" data-interval="false">
<div class="carousel-inner">
<div class="item" ng-class="{active:!$index}" ng-repeat="item in items">
// rest of the html
</div>
</div>
</div>
【问题讨论】:
标签: javascript angularjs carousel bootstrap-carousel