Wywołanie funkcji po ng-repeat

0

Robie pobieranie elementów do galerii w angularze, chciałbym po stworzeniu DOM za pomocą ng-repeat wykonać od razu funkcję która będzie formatować wczytane elementy. Dane pobierane są z WebApi. Próbowałem za pomocą dyrektywy ale nie wykonuje się ona zawsze:

Widok:

<div class="box" ng-repeat="gallery in listGallery" on-last-repeat="onEnd()">
               	 <img id="{{gallery.id}}" class="fancyDemo" ng-src="uploadRepository/{{gallery.fileName}}" alt="">
                <div class="thumb_title "><span class="text">{{gallery.title}}</span>&nbsp;</div>
                <p class="para">{{gallery.tagsGallery}}</p>
            </div>

Kontroler:

app.controller('designController', function ($scope, $http, $timeout) {
        showLoader();

        $http.get("api/GalleryList")
           .then(function (response) {

               galleryListGanerator(response.data.GalleryTitleList, 3);
               $scope.listGallery = galleryVisible;
              
               hideLoader();
               galleryVisible = [];

               $scope.onEnd = function () {
                   $timeout(function () {
                       alert('all done');
                   }, 1);
               };

           }, function (error) {
           });
    });

app.directive('onLastRepeat', function () {
        return {
            link: function(scope, element, attrs) {
                var $container = $('#content');

                $container.imagesLoaded(function () {
                    $container.masonry({
                        itemSelector: '.box',
                        isAnimated: true
                    });
                });

                if (scope.$last) {
                    scope.$eval(attrs.onLastRepeat);
                }
            }
        };
    });

Ciekawe jest że po wstawieniu "alert('all done');" javascript poprawnie sie wykonuje, a jak go usuwam to losowo. W czym może być problem? Proszę o rady

0

możesz porównać swój kod z innym przykładem http://www.nodewiz.biz/angular-js-final-callback-after-ng-repeat/

1 użytkowników online, w tym zalogowanych: 0, gości: 1