1

SOLVED: Here it is codepen link with correct code: Codepen

my angular bootstrap carousel shows images one on the other statically without "sliding", anyone know why?

This is my setup:

HOME.HTML:

<div id="slides_control">
 <div>
  <carousel interval="myInterval">
   <slide ng-repeat="slide in slides" active="slide.active">
    <img ng-src="{{slide.image}}">
   </slide>
  </carousel>
 </div>
</div>

APP.JS

angular.module('lbda', ['ngRoute', 'ui.bootstrap', 'lbda.controllers']).
 config(['$routeProvider',
  function($routeProvider) {
   $routeProvider.
    when('/home', {
     templateUrl: 'views/home.html',
     controller: 'CarouselCtrl'
   }).
   otherwise({
    redirectTo: ('/home')
   });
  }
 ]);

CAROUSEL.JS

angular.module('lbda.controllers').
  controller('CarouselCtrl', function ($scope) {
    $scope.active = 0;
    $scope.myInterval = 2000;
    $scope.slides = [
      {image: '../../images/carousel/1.jpg'},
      {image: '../../images/carousel/2.jpg'}
    ];
  })
2
  • Could you add a plunker or fiddle which demos the problem? Commented Apr 7, 2016 at 7:22
  • Edited, here is the link: codepen.io/paolopolix/pen/Wwdwbr Commented Apr 7, 2016 at 7:33

1 Answer 1

1

Below the ng-repeat, you'll need anchor links for the arrows:

<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
</a>

<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
</a>

You'll also need an id for your carousel: #myCarousel.

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

4 Comments

I've solved the problem (updated codepen: codepen.io/paolopolix/pen/Wwdwbr). But now transitions doesn't work and the text goes under the slides... why?
It seems you were mixing up ui-bootstrap and normal bootstrap. I haven't used ui-bootstrap either, so it wasn't working.
Yes.. I just used wrong tags 'carousel','slide' instead of 'uib-carousel' and 'uib-slide'.. Any idea for the other probs?
Solved! For transitions: I was missing the 'ngAnimate' dependency on the app.js; For text: I was using wrong css code. Thanks anyway! :)

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.