AngularJS: Infinite Scrolling

HTML

<script src='https://code.angularjs.org/1.0.0rc9/angular-1.0.0rc9.js' type='text/javascript'/>
<div id="men">
<div id="fixed" when-scrolled="loadMore()">
  <ul>
    <li id="li3" ng-repeat="i in items">{{i.id}}.test</li>
  </ul>  
</div></div>

CSS

#li3 {
  height: 120px;
  border-bottom: 1px solid gray;
}

#fixed  {
    height: 400px;
    overflow: auto;
}

JavaScript

function Main($scope) {
    $scope.items = [];
    
    var counter = 0;
    $scope.loadMore = function() {
        for (var i = 0; i < 5; i++) {
            $scope.items.push({id: counter});
            counter += 1;
        }
    };
    
    $scope.loadMore();
}

angular.module('scroll', []).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);
            }
        });
    };
});