AngularJS Tutorial - limitTo Filter








The limitTo filter creates a sub array or string that contains only the specified number of elements

It can either taken from the beginning or end, depending on whether the value is positive or negative.

If the limit exceeds the length, then the entire array or string will be returned.

Example

To take the first three letters of a string:

{{ "This is a test" | limitTo:3 }}

To take the last 6 characters of a string:

{{ "This is a test"| limitTo:-6 }}

To get the first element of the array:

{{ ['a', 'b', 'c', 'd', 'e', 'f'] | limitTo:1 }}