Angularjs Examples

AJS Examples

AngularJS LimitTo Filter

This AngularJS limitto filter is used to extract subset of array with specified number of items, beginning from some index in the array. The limitTo filter also works on strings.


{{ "Tech Strikers" | limitTo:4 }}
{{ [1,2,3,4,5,6,7,8,9] | limitTo:1 }}

AngularJS LimitTo Filter Example

<title>My first AngularJS limitto filter code</title>
<Script SRC="">
function setLimit($scope) {
    $scope.myArray = [1,2,3,4,5,6,7,8,9];
	$scope.arrayLimit = 6;
	$scope.myWebSite = "Tech Strikers";
	$scope.myWebSiteLimit = 4;
<div ng-app="">
<div ng-controller="setLimit"> 
Array Limit {{myArray}} to : <input type="integer" ng-model="arrayLimit">
<p>Array Output : {{ myArray | limitTo:arrayLimit }}</p>

String Limit {{myWebSite}} to : <input type="text" ng-model="myWebSiteLimit">
<p>String Output : {{ myWebSite | limitTo:myWebSiteLimit }}</p>

See Live Example