Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

Carousel not able to set active slide after assining new slides #2235

Closed
@kimvanhees

Description

@kimvanhees

I have a simple Carousel example. In this example on Plnkr I change the slides in my application. When I set the active slide after I change slides it goes to that slide and then slides out into oblivion or it goes to the first slide instead.

http://plnkr.co/edit/PJg9U4HZ1k5aSTSvbl3k?p=preview

angular.module('plunker', ['ui.bootstrap', 'ngTouch']);
function CarouselDemoCtrl($scope) {
    $scope.genderPerson = "men";
    $scope.myInterval = -1;
    $scope.slides = [];

    $scope.$watch("genderPerson", function( newValue, oldValue ) {
        $scope.MakeSlides();
    });

    $scope.MakeSlides = function() {
        var newSlides = [];
        for ( var i = 0; i < 10; i++ ) {
            newSlides[i] = { image: 'http://api.randomuser.me/portraits/' + $scope.genderPerson + '/' + i + '.jpg' };
         }
         $scope.slides = newSlides;
         if ( $scope.slides[6] ) {
             $scope.slides[6].active=true;
         }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions