Limit Angular Repeat

see http://stackoverflow.com/questions/16824853/way-to-ng-repeat-defined-number-of-times-instead-of-repeating-over-array modified from comment http://stackoverflow.com/a/16824961/1037948

by drzaus

HTML

<div ng-app ng-controller="Main">
   <div ng-repeat="item in items | limitTo:limit">
       {{item.name}}
   </div>
    
    <label>Set Limit: <input ng-model="limit" /></label>
</div>

JavaScript

function Main($scope){
    $scope.items = [{sort: 1, name: 'First'}, 
                    {sort: 2, name: 'Second'}, 
                    {sort: 3, name: 'Third'}, 
                    {sort: 4, name:'Last'}];
    
    $scope.limit = -2;
    }