Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No transition in angular ui bootstrap carousel

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.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();
  }
});

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?

like image 462
Hamza Ishak Avatar asked Jan 26 '26 10:01

Hamza Ishak


1 Answers

You 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>

like image 135
rpirsc13 Avatar answered Jan 28 '26 00:01

rpirsc13



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!