This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

ParamMap

Matrix and Query parameters.

See more...

      
      interface ParamMap {
  keys: string[]
  has(name: string): boolean
  get(name: string): string | null
  getAll(name: string): string[]
}
    

Description

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 correct type (either string or string[]).

The API is inspired by the URLSearchParams interface. see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

Properties

Property Description
keys: string[] Read-only.

Name of the parameters

Methods

has(name: string): boolean
      
      has(name: string): boolean
    

Parameters

name

Type: string.

Returns

boolean

Return a single value for the given parameter name:

  • the value when the parameter has a single value,
  • the first value if the parameter has multiple values,
  • null when there is no such parameter.
get(name: string): string | null
      
      get(name: string): string | null
    

Parameters

name

Type: string.

Returns

string | null

Return an array of values for the given parameter name.

getAll(name: string): string[]
      
      getAll(name: string): string[]
    

Parameters

name

Type: string.

Returns

string[]

If there is no such parameter, an empty array is returned.