Help Angular by taking a 1 minute survey!Go to surveyHome

HttpParams

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)
      
      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
      
      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
      
      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
      
      getAll(param: string): string[] | null
    
Parameters
param string
Returns

string[] | null

Get all the parameter names for this body.

keys(): string[]
      
      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
      
      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
      
      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
      
      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
      
      toString(): string
    
Parameters

There are no parameters.

Returns

string