Skip to content

Carousel.get method not working #21

@jakeweb

Description

@jakeweb

I'm trying to get access to my carousel. Here is controller, where I'm getting images from instagram via Promise.

angular.module('topfollowersApp')
    .controller('CounterCtrl', function($scope, instagramFactory,  Carousel) {
        instagramFactory.getMediaFromUserById({
            userId: user.instagramId,
            count: 12, 
            access_token: localStorage.getItem("access_token"),
        }).then(function(response) {
            $scope.mediaItems = response.data.data;
            var instagramCarousel = Carousel.get("instagramCarousel");
        }).catch(function(error) {
            console.log(error);
        });
}

and markup. All photos placed into $scope.mediaItems and carousel works fine.

<div ng-carousel ng-carousel-name="instagramCarousel" ng-carousel-timer="1000" ng-carousel-watch="mediaItems" ng-carousel-loop="false">
            <slidecontainer class="carousel-slides">
                <slide ng-repeat="item in mediaItems" class="carousel-example">
                    <img ng-src="{{item.images.standard_resolution.url}}">
                </slide>
            </slidecontainer>
        </div>

but I'm getting error Error: carousel with name 'instagramCarousel' does not exist when trying Carousel.get("instagramCarousel");.
Why it happens?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions