docs(API): 翻译完了 ParamMap

This commit is contained in:
Zhicheng Wang 2018-09-04 16:49:14 +08:00
parent ee075b2bbd
commit 8e6ce058ae
2 changed files with 35 additions and 3 deletions

View File

@ -82,8 +82,8 @@
[ ] | forms | 0.19 [ ] | forms | 0.19
[ ] | animations/state | 0.19 [ ] | animations/state | 0.19
[ ] | common | 0.19 [ ] | common | 0.19
[ ] | router/LoadChildren | 0.18 [x] | router/LoadChildren | 0.18
[ ] | router/ParamMap | 0.18 [x] | router/ParamMap | 0.18
[ ] | animations/trigger | 0.18 [ ] | animations/trigger | 0.18
[ ] | router/RouterLinkWithHref | 0.18 [ ] | router/RouterLinkWithHref | 0.18
[ ] | core/AfterViewInit | 0.18 [ ] | core/AfterViewInit | 0.18

View File

@ -16,6 +16,8 @@ import {UrlSegment, UrlSegmentGroup} from './url_tree';
* Name of the primary outlet. * Name of the primary outlet.
* *
* *
*
*
*/ */
export const PRIMARY_OUTLET = 'primary'; export const PRIMARY_OUTLET = 'primary';
@ -23,6 +25,7 @@ export const PRIMARY_OUTLET = 'primary';
* A collection of parameters. * A collection of parameters.
* *
* *
*
*/ */
export type Params = { export type Params = {
[key: string]: any [key: string]: any
@ -31,32 +34,60 @@ export type Params = {
/** /**
* Matrix and Query parameters. * Matrix and Query parameters.
* *
* `;``?`
*
* `ParamMap` makes it easier to work with parameters as they could have either a single value or * `ParamMap` makes it easier to work with parameters as they could have either a single value or
* multiple value. Because this should be known by the user, calling `get` or `getAll` returns the * multiple value. Because this should be known by the user, calling `get` or `getAll` returns the
* correct type (either `string` or `string[]`). * correct type (either `string` or `string[]`).
* *
* `ParamMap` 使
* `get` `getAll` `string` `string[]`
*
* The API is inspired by the URLSearchParams interface. * The API is inspired by the URLSearchParams interface.
* see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams * see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
* *
* *
* API URLSearchParams
* https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
*
*
*/ */
export interface ParamMap { export interface ParamMap {
has(name: string): boolean; has(name: string): boolean;
/** /**
* Return a single value for the given parameter name: * Return a single value for the given parameter name:
*
*
*
* - the value when the parameter has a single value, * - the value when the parameter has a single value,
*
*
*
* - the first value if the parameter has multiple values, * - the first value if the parameter has multiple values,
*
*
*
* - `null` when there is no such parameter. * - `null` when there is no such parameter.
*
* `null`
*
*/ */
get(name: string): string|null; get(name: string): string|null;
/** /**
* Return an array of values for the given parameter name. * Return an array of values for the given parameter name.
* *
*
*
* If there is no such parameter, an empty array is returned. * If there is no such parameter, an empty array is returned.
*
*
*/ */
getAll(name: string): string[]; getAll(name: string): string[];
/** Name of the parameters */ /** Name of the parameters
*
*
*/
readonly keys: string[]; readonly keys: string[];
} }
@ -92,6 +123,7 @@ class ParamsAsMap implements ParamMap {
* Convert a `Params` instance to a `ParamMap`. * Convert a `Params` instance to a `ParamMap`.
* *
* *
* `Params` `ParamMap`
*/ */
export function convertToParamMap(params: Params): ParamMap { export function convertToParamMap(params: Params): ParamMap {
return new ParamsAsMap(params); return new ParamsAsMap(params);