AngularJS Tutorial - Filter array with limitTo filter








The following code shows how to use Filter array with limitTo filter.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
function Ctrl($scope) {<!--from w  w w  . java2  s  . co m-->
  $scope.numbers = [1,2,3,4,5,6,7,8,9];
  $scope.limit = 3;
  $scope.xss = '<b>testing</b>';
}
</script>
</head>
<body>
  <div ng-app="">
  <div ng-controller="Ctrl">
    Limit {{numbers}} to: 
    <input type="integer" ng-model="limit">
    <p>Output: {{ numbers | limitTo:limit }}</p>
      <p>{{xss}}</p>
  </div>
</div>
</body>
</html>

The code above is rendered as follows: