Jun Duan
Jun Duan

Reputation: 218

Angular ui bootstrap carousel won't slide after setting a slide's active property to true

Here's a fork of the plunker of uib-carousel on ui.bootstrap.

I added a line in the controller after the for loop for populating $scope.slides:

$scope.slides[1].active = true;

I want to pre-select a certain slide, however, after adding this line, the uib-carousel stopped sliding.

This is the intended behaviour? Or am I going about setting the active slide the wrong way?

Upvotes: 2

Views: 438

Answers (1)

beaver
beaver

Reputation: 17647

Try to delay that operation wrapping it with $timeout()

$timeout(function() {
  $scope.slides[1].active = true;  
})

Your Plunker updated: http://plnkr.co/edit/9aT26y9q8ivr0Ebagdsa?p=preview

Upvotes: 1

Related Questions