docs(API): 翻译完了 SlicePipe

This commit is contained in:
Zhicheng Wang 2018-09-04 14:50:06 +08:00
parent a033f25b13
commit adb6be6a02
2 changed files with 46 additions and 1 deletions

View File

@ -60,7 +60,7 @@
[x] | router/CanActivate | 0.27 [x] | router/CanActivate | 0.27
[x] | router | 0.26 [x] | router | 0.26
[ ] | animations/style | 0.25 [ ] | animations/style | 0.25
[ ] | common/SlicePipe | 0.25 [x] | common/SlicePipe | 0.25
[ ] | router/Event | 0.25 [ ] | router/Event | 0.25
[ ] | common/JsonPipe | 0.25 [ ] | common/JsonPipe | 0.25
[x] | forms/FormArray | 0.25 [x] | forms/FormArray | 0.25

View File

@ -15,27 +15,43 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* *
* Creates a new `Array` or `String` containing a subset (slice) of the elements. * Creates a new `Array` or `String` containing a subset (slice) of the elements.
* *
* `Array` `String` slice
*
* All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()` * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
* and `String.prototype.slice()`. * and `String.prototype.slice()`.
* *
* JavaScript API `Array.prototype.slice()` `String.prototype.slice()`
*
* When operating on an `Array`, the returned `Array` is always a copy even when all * When operating on an `Array`, the returned `Array` is always a copy even when all
* the elements are being returned. * the elements are being returned.
* *
* `Array` `Array` 使
*
* When operating on a blank value, the pipe returns the blank value. * When operating on a blank value, the pipe returns the blank value.
* *
*
*
* ### List Example * ### List Example
* *
* ###
*
* This `ngFor` example: * This `ngFor` example:
* *
* `ngFor`
*
* {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'} * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
* *
* produces the following: * produces the following:
* *
*
*
* <li>b</li> * <li>b</li>
* <li>c</li> * <li>c</li>
* *
* ## String Examples * ## String Examples
* *
* ##
*
* {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'} * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
* *
* *
@ -45,18 +61,47 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
export class SlicePipe implements PipeTransform { export class SlicePipe implements PipeTransform {
/** /**
* @param value a list or a string to be sliced. * @param value a list or a string to be sliced.
*
*
*
* @param start the starting index of the subset to return: * @param start the starting index of the subset to return:
*
*
*
* - **a positive integer**: return the item at `start` index and all items after * - **a positive integer**: return the item at `start` index and all items after
* in the list or string expression. * in the list or string expression.
*
* **** `start`
*
* - **a negative integer**: return the item at `start` index from the end and all items after * - **a negative integer**: return the item at `start` index from the end and all items after
* in the list or string expression. * in the list or string expression.
*
* **** `start`
*
* - **if positive and greater than the size of the expression**: return an empty list or * - **if positive and greater than the size of the expression**: return an empty list or
* string. * string.
*
* ****
*
* - **if negative and greater than the size of the expression**: return entire list or string. * - **if negative and greater than the size of the expression**: return entire list or string.
*
* ****
*
* @param end the ending index of the subset to return: * @param end the ending index of the subset to return:
*
*
*
* - **omitted**: return all items until the end. * - **omitted**: return all items until the end.
*
* ****
*
* - **if positive**: return all items before `end` index of the list or string. * - **if positive**: return all items before `end` index of the list or string.
*
* **** `end`
*
* - **if negative**: return all items before `end` index from the end of the list or string. * - **if negative**: return all items before `end` index from the end of the list or string.
*
* **** `end`
*/ */
transform(value: any, start: number, end?: number): any { transform(value: any, start: number, end?: number): any {
if (value == null) return value; if (value == null) return value;