3

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?

1 Answer 1

11

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.