W3cubDocs

/Angular 7

HttpParams

class

An HTTP request/response body that represents serialized parameters, per the MIME type application/x-www-form-urlencoded.

See more...

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

constructor(options: HttpParamsOptions = {} as HttpParamsOptions)

Parameters
options HttpParamsOptions

Optional. Default is {} as HttpParamsOptions.

Methods

Check whether the body has one or more values for the given parameter name.

has(param: string): boolean

Parameters
param string
Returns

boolean

Get the first value for the given parameter name, or null if it's not present.

get(param: string): string | null

Parameters
param string
Returns

string | null

Get all values for the given parameter name, or null if it's not present.

getAll(param: string): string[] | null

Parameters
param string
Returns

string[] | null

Get all the parameter names for this body.

keys(): string[]

Parameters

There are no parameters.

Returns

string[]

Construct a new body with an appended value for the given parameter name.

append(param: string, value: string): HttpParams

Parameters
param string
value string
Returns

HttpParams

Construct a new body with a new value for the given parameter name.

set(param: string, value: string): HttpParams

Parameters
param string
value string
Returns

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.

delete(param: string, value?: string): HttpParams

Parameters
param string
value string

Optional. Default is undefined.

Returns

HttpParams

Serialize the body to an encoded string, where key-value pairs (separated by =) are separated by &s.

toString(): string

Parameters

There are no parameters.

Returns

string

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v7.angular.io/api/common/http/HttpParams