docs(API): 翻译完了 HttpParams

This commit is contained in:
Zhicheng Wang 2018-09-04 11:05:45 +08:00
parent 82ba447ca0
commit d1985fc7d1
2 changed files with 38 additions and 4 deletions

View File

@ -51,7 +51,7 @@
[x] | router/RouterLinkActive | 0.38
[x] | core/TemplateRef | 0.38
[x] | forms/FormBuilder | 0.37
[ ] | common/http/HttpParams | 0.35
[x] | common/http/HttpParams | 0.35
[ ] | core/OnChanges | 0.35
[ ] | forms/FormControlName | 0.34
[x] | core/Output | 0.33

View File

@ -9,8 +9,11 @@
/**
* A codec for encoding and decoding parameters in URLs.
*
* URL
*
* Used by `HttpParams`.
*
* `HttpParams` 使
*
**/
export interface HttpParameterCodec {
@ -25,6 +28,7 @@ export interface HttpParameterCodec {
* A `HttpParameterCodec` that uses `encodeURIComponent` and `decodeURIComponent` to
* serialize and parse URL parameter keys and values.
*
* `HttpParameterCodec`使 `encodeURIComponent` `decodeURIComponent` URL key value
*
*/
export class HttpUrlEncodingCodec implements HttpParameterCodec {
@ -73,18 +77,29 @@ interface Update {
op: 'a'|'d'|'s';
}
/** Options used to construct an `HttpParams` instance. */
/** Options used to construct an `HttpParams` instance.
*
* `HttpParams`
*/
export interface HttpParamsOptions {
/**
* String representation of the HTTP params in URL-query-string format. Mutually exclusive with
* `fromObject`.
*
* HTTP URL `fromObject`
*/
fromString?: string;
/** Object map of the HTTP params. Mutally exclusive with `fromString`. */
/** Object map of the HTTP params. Mutally exclusive with `fromString`.
*
* HTTP `fromString`
*/
fromObject?: {[param: string]: string | string[]};
/** Encoding codec used to parse and serialize the params. */
/** Encoding codec used to parse and serialize the params.
*
*
*/
encoder?: HttpParameterCodec;
}
@ -92,8 +107,11 @@ export interface HttpParamsOptions {
* An HTTP request/response body that represents serialized parameters,
* per the MIME type `application/x-www-form-urlencoded`.
*
* HTTP / MIME `application/x-www-form-urlencoded`
*
* This class is immutable - all mutation operations return a new instance.
*
* -
*
*/
export class HttpParams {
@ -122,6 +140,8 @@ export class HttpParams {
/**
* Check whether the body has one or more values for the given parameter name.
*
* `body`
*/
has(param: string): boolean {
this.init();
@ -130,6 +150,8 @@ export class HttpParams {
/**
* Get the first value for the given parameter name, or `null` if it's not present.
*
* `null`
*/
get(param: string): string|null {
this.init();
@ -139,6 +161,8 @@ export class HttpParams {
/**
* Get all values for the given parameter name, or `null` if it's not present.
*
* `null`
*/
getAll(param: string): string[]|null {
this.init();
@ -147,6 +171,8 @@ export class HttpParams {
/**
* Get all the parameter names for this body.
*
* `body`
*/
keys(): string[] {
this.init();
@ -155,11 +181,15 @@ export class HttpParams {
/**
* Construct a new body with an appended value for the given parameter name.
*
* `body`
*/
append(param: string, value: string): HttpParams { return this.clone({param, value, op: 'a'}); }
/**
* Construct a new body with a new value for the given parameter name.
*
* `body`
*/
set(param: string, value: string): HttpParams { return this.clone({param, value, op: 's'}); }
@ -167,12 +197,16 @@ export class HttpParams {
* Construct a new body with either the given value for the given parameter
* removed, if a value is given, or all values for the given parameter removed
* if not.
*
* `body` `value` `value` `param` `value` `param`
*/
delete (param: string, value?: string): HttpParams { return this.clone({param, value, op: 'd'}); }
/**
* Serialize the body to an encoded string, where key-value pairs (separated by `=`) are
* separated by `&`s.
*
* `body` key-value `=` `&`
*/
toString(): string {
this.init();