That is what finally I've done
I am using jquery to detect when I am at 300 px or less close to the bottom, in that case I call onScrollBottomEvent() from my controller, notice that this function may be called n times during scroll if user is inside of the 300px margin and he keeps going down.
<script type="text/javascript">
var lastScrollTop = 0;
$(window).scroll(function(event) {
scrolled = $(window).scrollTop() + $(window).height();
scrollMax = $('#container').height() + 50;
if(scrolled >= (scrollMax-300)) {
angular.element('#container').scope().onScrollBottomEvent();
}
});
</script>
then onScrollBottomEvent() calls loadNextPage() using apply() [important!] Inside loadNextPage I set the flag onLoadMoreRequested to true, because I just need to call just once in order to load the next page instead of calling on every pixel scroll
$scope.onScrollBottomEvent = function(){
$log.log("onScrollBottomEvent()");
$scope.$apply(loadNextPage);
}
function loadNextPage(){
$log.log("loadNextPage()");
// execute only if there is other request on fly
if (!$scope.onLoadMoreRequested){
$scope.onLoadMoreRequested = true;
$scope.appendNewItems($scope.search.data, $scope.lastLoadedPage + 1);
}
}
finally I call the method to invoke the service
$scope.appendNewItems = function(search, page){
$log.log("Loading items request for page " + page);
$scope.footerProgressVisible = true;
if ($scope.lastSearch != $scope.search.data){
page = 0; // if search has changed, set page to zero
}
srvItems.getItems(search, function(result, page){
$scope.footerProgressVisible = false;
if (result!=null){
$scope.items.push.apply($scope.items, result);
$scope.lastLoadedPage = page;
$scope.onLoadMoreRequested = false;
$scope.lastSearch = $scope.search.data;
}
},
$scope.currentCategoryId,
page);
};
The key line is
$scope.items.push.apply($scope.items, result);
which will expand my ng-repeat automatically