angular ui bootstrap 轮播中没有过渡
No transition in angular ui bootstrap carousel
我在这里重新使用了基于 angular 的轮播:
http://codepen.io/hamzaisaac/pen/avaVYK
标记:
<div ng-app="MyApp">
<div ng-controller="CarouselDemoCtrl">
<div style="height: 305px">
<uib-carousel interval="myInterval" no-wrap="noWrapSlides">
<uib-slide ng-repeat="slide in slides" active="slide.active">
<img ng-src="{{slide.image}}" style="margin:auto;">
<div class="carousel-caption">
<h4>Slide {{$index}}</h4>
<p>{{slide.text}}</p>
</div>
</uib-slide>
</uib-carousel>
</div>
</div>
</div>
控制器:
angular.module('MyApp', ['ui.bootstrap'])
.controller('CarouselDemoCtrl', function ($scope) {
$scope.myInterval = 5000;
$scope.noWrapSlides = false;
var slides = $scope.slides = [];
$scope.addSlide = function() {
var newWidth = 1000 + slides.length + 1;
slides.push({
image: '//placekitten.com/' + newWidth + '/300',
text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' +
['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
});
};
for (var i=0; i<4; i++) {
$scope.addSlide();
}
});
可以,但是我在原代码中无法实现同样的转场效果:
https://angular-ui.github.io/bootstrap/#carousel
为什么?我已经包含了所有依赖项,包括 Angularjs 和 UI Bootstrap。
我在这里遗漏了什么吗?
您缺少 ng-animate 依赖项。
angular.module('MyApp', ['ngAnimate', 'ui.bootstrap'])
如果您使用的是 Bower,那么只需使用
安装依赖项
bower install angular-animate
或使用 npm
npm install angular-animate
并在您的 index.html
中包含 js
<script src="/path/to/angular-animate/angular-animate.js"></script>
我在这里重新使用了基于 angular 的轮播: http://codepen.io/hamzaisaac/pen/avaVYK
标记:
<div ng-app="MyApp">
<div ng-controller="CarouselDemoCtrl">
<div style="height: 305px">
<uib-carousel interval="myInterval" no-wrap="noWrapSlides">
<uib-slide ng-repeat="slide in slides" active="slide.active">
<img ng-src="{{slide.image}}" style="margin:auto;">
<div class="carousel-caption">
<h4>Slide {{$index}}</h4>
<p>{{slide.text}}</p>
</div>
</uib-slide>
</uib-carousel>
</div>
</div>
</div>
控制器:
angular.module('MyApp', ['ui.bootstrap'])
.controller('CarouselDemoCtrl', function ($scope) {
$scope.myInterval = 5000;
$scope.noWrapSlides = false;
var slides = $scope.slides = [];
$scope.addSlide = function() {
var newWidth = 1000 + slides.length + 1;
slides.push({
image: '//placekitten.com/' + newWidth + '/300',
text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' +
['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
});
};
for (var i=0; i<4; i++) {
$scope.addSlide();
}
});
可以,但是我在原代码中无法实现同样的转场效果: https://angular-ui.github.io/bootstrap/#carousel
为什么?我已经包含了所有依赖项,包括 Angularjs 和 UI Bootstrap。 我在这里遗漏了什么吗?
您缺少 ng-animate 依赖项。
angular.module('MyApp', ['ngAnimate', 'ui.bootstrap'])
如果您使用的是 Bower,那么只需使用
安装依赖项bower install angular-animate
或使用 npm
npm install angular-animate
并在您的 index.html
<script src="/path/to/angular-animate/angular-animate.js"></script>