compact / angular-bootstrap-lightbox

An AngularJS lightbox built using UI Bootstrap Modal.
http://compact.github.io/angular-bootstrap-lightbox/
MIT License
306 stars 134 forks source link

Lightbox is undefined #63

Open cttech opened 8 years ago

cttech commented 8 years ago

I am trying to user angular-bootstrap-lightbox via angular directive.

app.directive('productBuyers', ['Product', function(Product, Lightbox) {

    return {

        restrict : 'E',

        scope : {},

        template : '<div>' +
            '<p class="product-buyers-header bold" ng-show="photos.length">Others who have bought this product:</p>' +
            '<div class="product-buyers-container">' +
            '<div class="product-buyer placeholder square" ng-hide="photos.length"></div>' + 
            '<div class="product-buyer square" ng-click="openLightboxModal($index)" ng-repeat="photo in photos | limitTo:3" ng-style="{\'background-image\':\'url(\' + photo.image + \')\'}"></div>' + 
            '<div class="clear"></div>' +
            '</div>' +
            '</div>',

        link : function($scope, element, attrs) {

            $scope.photos = [];

            function getImages() {

                Product.customerPhotos(attrs.productId).success(function(response) {

                    $scope.photos = response.data;

                    Squares.init();

                }).error(function(response) {

                    console.log("There was a problem getting the product images");

                });

            }
            $scope.openLightboxModal = function (index) {
                Lightbox.openModal($scope.photos, index);
              };
            getImages();

        }

    }

}]);

it says " Lightbox is undefined". I am not sure how can I use it with directive. Is there any way to do it?

cemarguvanli commented 7 years ago

app.directive('productBuyers', ['Product', function(Product, Lightbox) {

change this; app.directive('productBuyers', ['Product', 'Lightbox', function(Product, Lightbox) {

thats the problem.