डाउनलोड पी.डी.एफ. ई-बुक्स
AJS - Filters limitTo

limitTo ये filter; Number के रूप में दिए गए limit तक new array को return करता है |

Syntax for limitTo Filter in AngularJS

{{expression | limitTo : limit : start}}

Parameter for limitTo Filter in AngularJS

limit : यहाँ पर number of elements दिए जाते है |

start : किस element से start करना है उस element की position दी जाती है | position '0' से शुरू होती है |


Example for limitTo Filter in AngularJS

Source Code :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>
<div ng-app="">

<div ng-init="arr = ['Rakesh', 'Mangesh', 'Raj', 'Monohar', 'Shanshank', 'Maria']">
<p>Using Array</p>
arr | limitTo : 3 - <b>{{arr | limitTo : 3 : 0}}</b><br />
arr | limitTo : 3 : 1 - <b>{{arr | limitTo : 3 : 1}}</b><br />
</div>
<hr />

<div ng-init="str = 'Hello World'">
<p>Using String</p>
str | limitTo : 3 - <b>{{str | limitTo : 3 : 0}}</b><br />
str | limitTo : 3 : 1 - <b>{{str | limitTo : 3 : 1}}</b><br />
</div>
<hr />

<div ng-init="num = 45785121">
<p>Using String</p>
num | limitTo : 3 - <b>{{num | limitTo : 3 : 0}}</b><br />
num | limitTo : 3 : 1 - <b>{{num | limitTo : 3 : 1}}</b><br />
</div>
<hr />

<div ng-init="obj = [{'name':'Rakesh'},{'name':'Ramesh'},{'name':'Mangesh'},{'name':'Radha'},{'name':'Kamalesh'}]">
<p>Using Object</p>
num | limitTo : 3 - <b>{{obj | limitTo : 3 : 0}}</b><br />
num | limitTo : 3 : 1 - <b>{{obj | limitTo : 3 : 1}}</b><br />
</div>

</div>

</body>
</html>
Output :

Using Array

arr | limitTo : 3 - {{arr | limitTo : 3 : 0}}
arr | limitTo : 3 : 1 - {{arr | limitTo : 3 : 1}}

Using String

str | limitTo : 3 - {{str | limitTo : 3 : 0}}
str | limitTo : 3 : 1 - {{str | limitTo : 3 : 1}}

Using String

num | limitTo : 3 - {{num | limitTo : 3 : 0}}
num | limitTo : 3 : 1 - {{num | limitTo : 3 : 1}}

Using Object

num | limitTo : 3 - {{obj | limitTo : 3 : 0}}
num | limitTo : 3 : 1 - {{obj | limitTo : 3 : 1}}