akoenig / angular-deckgrid

A lightweight masonry-like grid for AngularJS.
http://akoenig.github.io/angular-deckgrid
MIT License
1.09k stars 191 forks source link

Scroll down to load more #96

Open hieugie opened 9 years ago

hieugie commented 9 years ago

Let's see my code below Did i do something wrong ?

<div class="container" ng-controller="gridController" when-scrolled="loadMore()">
    <div deckgrid source="photos" cardTemplate="templates/card.html" class="deckgrid" ></div>
</div>

studiouskids.directive('whenScrolled', function() { return function(scope, elm, attr) { var raw = elm[0]; elm.bind('scroll', function() { if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) { scope.$apply(attr.whenScrolled); } }); }; });

$scope.loadMore = function() { $scope.photos.push({id: 'photo-1', title: 'Photo', src: 'http://lorempixel.com/400/300/abstract', }