HttpParams
class
An HTTP request/response body that represents serialized parameters, per the MIME type application/x-www-form-urlencoded
.
class HttpParams { constructor(options: HttpParamsOptions = {} as HttpParamsOptions) has(param: string): boolean get(param: string): string | null getAll(param: string): string[] | null keys(): string[] append(param: string, value: string): HttpParams set(param: string, value: string): HttpParams delete(param: string, value?: string): HttpParams toString(): string }
Description
This class is immutable; all mutation operations return a new instance.
Constructor
|
options | HttpParamsOptions | Optional. Default is |
Methods
has() | |||
---|---|---|---|
Reports whether the body includes one or more values for a given parameter. | |||
|
param | string | The parameter name. |
Returns
boolean
: True if the parameter has one or more values, false if it has no value or is not present.
get() | |||
---|---|---|---|
Retrieves the first value for a parameter. | |||
|
param | string | The parameter name. |
Returns
string | null
: The first value of the given parameter, or null
if the parameter is not present.
getAll() | |||
---|---|---|---|
Retrieves all values for a parameter. | |||
|
param | string | The parameter name. |
Returns
string[] | null
: All values in a string array, or null
if the parameter not present.
keys() |
---|
Retrieves all the parameters for this body. |
|
append() | ||||||
---|---|---|---|---|---|---|
Appends a new value to existing values for a parameter. | ||||||
|
param | string | The parameter name. |
value | string | The new value to add. |
Returns
HttpParams
: A new body with the appended value.
set() | ||||||
---|---|---|---|---|---|---|
Replaces the value for a parameter. | ||||||
|
param | string | The parameter name. |
value | string | The new value. |
Returns
HttpParams
: A new body with the new value.
delete() | ||||||
---|---|---|---|---|---|---|
Removes a given value or all values from a parameter. | ||||||
|
param | string | The parameter name. |
value | string | The value to remove, if provided. Optional. Default is |
Returns
HttpParams
: A new body with the given value removed, or with all values removed if no value is specified.
toString() |
---|
Serializes the body to an encoded string, where key-value pairs (separated by |
|
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v9.angular.io/api/common/http/HttpParams