admin管理员组文章数量:1326146
I've re-used the angular-based carousel here:
Markup:
<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>
Controller:
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/' + 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();
}
});
It works, but I can't achieve the same transition effect in the original code:
Why? I've included all of the dependencies including Angularjs and UI Bootstrap. Is there anything that I've missed here?
I've re-used the angular-based carousel here: http://codepen.io/hamzaisaac/pen/avaVYK
Markup:
<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>
Controller:
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./' + 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();
}
});
It works, but I can't achieve the same transition effect in the original code: https://angular-ui.github.io/bootstrap/#carousel
Why? I've included all of the dependencies including Angularjs and UI Bootstrap. Is there anything that I've missed here?
Share Improve this question asked Nov 8, 2015 at 18:32 Hamza IshakHamza Ishak 3604 silver badges16 bronze badges1 Answer
Reset to default 11You are missing the ng-animate dependency.
angular.module('MyApp', ['ngAnimate', 'ui.bootstrap'])
If you are using bower then simply install the dependency using
bower install angular-animate
OR using npm
npm install angular-animate
and including the js in your index.html
<script src="/path/to/angular-animate/angular-animate.js"></script>
本文标签: javascriptNo transition in angular ui bootstrap carouselStack Overflow
版权声明:本文标题:javascript - No transition in angular ui bootstrap carousel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742189793a2429999.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论