docs(pipes): updated pipe documentation
This commit is contained in:
@ -12,48 +12,37 @@ import {StringWrapper, isArray, isBlank, isString} from '../facade/lang';
|
||||
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
|
||||
|
||||
/**
|
||||
* Creates a new List or String containing only a subset (slice) of the
|
||||
* elements.
|
||||
* @ngModule CommonModule
|
||||
* @whatItDoes Creates a new List or String containing a subset (slice) of the elements.
|
||||
* @howToUse `array_or_string_expression | slice:start[:end]`
|
||||
* @description
|
||||
*
|
||||
* The starting index of the subset to return is specified by the `start` parameter.
|
||||
* Where the input expression is a `List` or `String`, and:
|
||||
* - `start`: The starting index of the subset to return.
|
||||
* - **a positive integer**: return the item at `start` index and all items after
|
||||
* in the list or string expression.
|
||||
* - **a negative integer**: return the item at `start` index from the end and all items after
|
||||
* in the list or string expression.
|
||||
* - **if positive and greater than the size of the expression**: return an empty list or string.
|
||||
* - **if negative and greater than the size of the expression**: return entire list or string.
|
||||
* - `end`: The ending index of the subset to return.
|
||||
* - **omitted**: return all items until the end.
|
||||
* - **if positive**: return all items before `end` index of the list or string.
|
||||
* - **if negative**: return all items before `end` index from the end of the list or string.
|
||||
*
|
||||
* The ending index of the subset to return is specified by the optional `end` parameter.
|
||||
*
|
||||
* ### Usage
|
||||
*
|
||||
* expression | slice:start[:end]
|
||||
*
|
||||
* All behavior is based on the expected behavior of the JavaScript API
|
||||
* Array.prototype.slice() and String.prototype.slice()
|
||||
*
|
||||
* Where the input expression is a [List] or [String], and `start` is:
|
||||
*
|
||||
* - **a positive integer**: return the item at _start_ index and all items after
|
||||
* in the list or string expression.
|
||||
* - **a negative integer**: return the item at _start_ index from the end and all items after
|
||||
* in the list or string expression.
|
||||
* - **`|start|` greater than the size of the expression**: return an empty list or string.
|
||||
* - **`|start|` negative greater than the size of the expression**: return entire list or
|
||||
* string expression.
|
||||
*
|
||||
* and where `end` is:
|
||||
*
|
||||
* - **omitted**: return all items until the end of the input
|
||||
* - **a positive integer**: return all items before _end_ index of the list or string
|
||||
* expression.
|
||||
* - **a negative integer**: return all items before _end_ index from the end of the list
|
||||
* or string expression.
|
||||
* All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
|
||||
* and `String.prototype.slice()`.
|
||||
*
|
||||
* When operating on a [List], the returned list is always a copy even when all
|
||||
* the elements are being returned.
|
||||
*
|
||||
* When operating on a blank value, returns it.
|
||||
* When operating on a blank value, the pipe returns the blank value.
|
||||
*
|
||||
* ## List Example
|
||||
*
|
||||
* This `ngFor` example:
|
||||
*
|
||||
* {@example core/pipes/ts/slice_pipe/slice_pipe_example.ts region='SlicePipe_list'}
|
||||
* {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
|
||||
*
|
||||
* produces the following:
|
||||
*
|
||||
@ -62,7 +51,7 @@ import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
|
||||
*
|
||||
* ## String Examples
|
||||
*
|
||||
* {@example core/pipes/ts/slice_pipe/slice_pipe_example.ts region='SlicePipe_string'}
|
||||
* {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
|
Reference in New Issue
Block a user