View source Improve this doc

# `limitTo`
filter in module `ng`

## Description

Creates a new array or string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array or string, as specified by the value and sign (positive or negative) of `limit`.

Note: This function is used to augment the `Array` type in Angular expressions. See `ng.$filter` for more information about Angular arrays.

## Usage

    filter:limitTo(input, limit);

#### Parameters

Param | Type | Details
--- | --- | ---
input | Array string | Source array or string to be limited.
limit | string number | The length of the returned array or string. If the `limit` number is positive, `limit` number of items from the beginning of the source array/string are copied. If the number is negative, `limit` number of items from the end of the source array/string are copied. The `limit` will be trimmed if it exceeds `array.length`

#### Returns

Array|string | A new sub-array or substring of length `limit` or less if input array had less than `limit` elements.

## Example

#### Source

## Demo