95 lines
1.9 KiB
Plaintext
95 lines
1.9 KiB
Plaintext
|
|
p.location-badge.
|
|
exported from <a href='../pipes'>angular2/pipes</a>
|
|
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.33/modules/angular2/src/change_detection/pipes/limit_to_pipe.ts#L12-L75">angular2/src/change_detection/pipes/limit_to_pipe.ts (line 12)</a>
|
|
|
|
:markdown
|
|
Creates a new List or String containing only a prefix/suffix of the
|
|
elements.
|
|
|
|
The number of elements to return is specified by the `limitTo` parameter.
|
|
|
|
# Usage
|
|
|
|
expression | limitTo:number
|
|
|
|
Where the input expression is a [List] or [String], and `limitTo` is:
|
|
|
|
- **a positive integer**: return _number_ items from the beginning of the list or string
|
|
expression.
|
|
- **a negative integer**: return _number_ items from the end of the list or string expression.
|
|
- **`|limitTo|` greater than the size of the expression**: return the entire expression.
|
|
|
|
When operating on a [List], the returned list is always a copy even when all
|
|
the elements are being returned.
|
|
|
|
# Examples
|
|
|
|
## List Example
|
|
|
|
Assuming `var collection = ['a', 'b', 'c']`, this `ng-for` directive:
|
|
|
|
<li *ng-for="var i in collection | limitTo:2">{{i}}</li>
|
|
|
|
produces the following:
|
|
|
|
<li>a</li>
|
|
<li>b</li>
|
|
|
|
## String Examples
|
|
|
|
{{ 'abcdefghij' | limitTo: 4 }} // output is 'abcd'
|
|
{{ 'abcdefghij' | limitTo: -4 }} // output is 'ghij'
|
|
{{ 'abcdefghij' | limitTo: -100 }} // output is 'abcdefghij'
|
|
|
|
|
|
.l-main-section
|
|
h2 Members
|
|
.l-sub-section
|
|
h3 supports
|
|
|
|
|
|
pre.prettyprint
|
|
code.
|
|
supports(obj: any)
|
|
|
|
:markdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.l-sub-section
|
|
h3 transform
|
|
|
|
|
|
pre.prettyprint
|
|
code.
|
|
transform(value: any, args?: List<any>)
|
|
|
|
:markdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.l-sub-section
|
|
h3 onDestroy
|
|
|
|
|
|
pre.prettyprint
|
|
code.
|
|
onDestroy()
|
|
|
|
:markdown
|
|
|
|
|
|
|
|
|
|
|
|
|