An internal class which implements ParamTypeDefinition.

A ParamTypeDefinition is a plain javascript object used to register custom parameter types. When a param type definition is registered, an instance of this class is created internally.

This class has naive implementations for all the ParamTypeDefinition methods.

Used by UrlMatcher when matching or formatting URLs, or comparing and validating parameter values.

#### Example:

    var paramTypeDef = {
      decode: function(val) { return parseInt(val, 10); },
      encode: function(val) { return val && val.toString(); },
      equals: function(a, b) { return this.is(a) && a === b; },
      is: function(val) { return angular.isNumber(val) && isFinite(val) && val % 1 === 0; },
      pattern: /\d+/
    }

    var paramType = new ParamType(paramTypeDef);

### Hierarchy

- ParamType

### Implements

- ParamTypeDefinition

## Index

### Constructors

- constructor

### Properties

- dynamic
- inherit
- name
- pattern
- raw

### Methods

- $asArray
- $normalize
- $subPattern
- decode
- encode
- equals
- is
- toString

## Constructors

- new ParamType(def: ParamTypeDefinition): ParamType

- #### Parameters

  - ##### def ParamTypeDefinition

    :

    A configuration object which contains the custom type definition. The object's properties will override the default methods and/or pattern in `ParamType`'s public interface.

  #### Returns ParamType

  :

  a new ParamType object

  - Defined in params/paramType.ts:44

## Properties

dynamic: boolean

Dynamic flag

Dynamic flag

When `dynamic` is `true`, changes to the parameter value will not cause the state to be entered/exited.

Normally, if a parameter value changes, the state which declared that the parameter will be reloaded (entered/exited). When a parameter is `dynamic`, a transition still occurs, but it does not cause the state to exit/enter.

Default: `false`

Implementation of ParamTypeDefinition.dynamic

- Defined in params/paramType.ts:42

inherit: boolean = true

Enables/disables inheriting of parameter values (of this type)

Enables/disables inheriting of parameter values (of this type)

When a transition is run with TransitionOptions.inherit set to `true`, the current param values are inherited in the new transition. However, parameters whose type has `inherit: false` set will not be inherited.

The internal parameter type of `hash` has `inherit: false`. This is used to disable inheriting of the hash value (`#`) on subsequent transitions.

#### Example:

    $state.go('home', { '#': 'inboxAnchor' });
    ...
    // "#" is not inherited.
    // The value of the "#" parameter will be `null`
    // The url's hash will be cleared.
    $state.go('home.nest');

See also TransitionOptions.inherit and ParamDeclaration.inherit

Implementation of ParamTypeDefinition.inherit

- Defined in params/paramType.ts:44

name: string

The name/id of the parameter type

The name/id of the parameter type

- Defined in params/paramType.ts:38

pattern: RegExp = /.*/

A regular expression that matches the encoded parameter type

A regular expression that matches the encoded parameter type

This regular expression is used to match an encoded parameter value in the URL.

For example, if your type encodes as a dash-separated numbers, match that here: `new RegExp("[0-9]+(?:-[0-9]+)*")`.

There are some limitations to these regexps:

- No capturing groups are allowed (use non-capturing groups: `(?: )`)
- No pattern modifiers like case insensitive
- No start-of-string or end-of-string: `/^foo$/`

Implementation of ParamTypeDefinition.pattern

- Defined in params/paramType.ts:36

raw: boolean

Disables url-encoding of parameter values

Disables url-encoding of parameter values

If a parameter type is declared `raw`, it will not be url-encoded. Custom encoding can still be applied in the encode function.

### Decoding warning

The decoding behavior of raw parameters is not defined. See: ParamDeclaration.raw for details

Implementation of ParamTypeDefinition.raw

- Defined in params/paramType.ts:40

## Methods

- $asArray(mode: true | false | "auto", isSearch: boolean): any

- Wraps an existing custom ParamType as an array of ParamType, depending on 'mode'. e.g.:

  - urlmatcher pattern "/path?{queryParam[]:int}"
  - url: "/path?queryParam=1&queryParam=2
  - $stateParams.queryParam will be [1, 2] if `mode` is "auto", then
  - url: "/path?queryParam=1 will create $stateParams.queryParam: 1
  - url: "/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]

- Wraps an existing custom ParamType as an array of ParamType, depending on 'mode'. e.g.:

  - urlmatcher pattern "/path?{queryParam[]:int}"
  - url: "/path?queryParam=1&queryParam=2
  - $stateParams.queryParam will be [1, 2] if `mode` is "auto", then
  - url: "/path?queryParam=1 will create $stateParams.queryParam: 1
  - url: "/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]

  #### Parameters

  - ##### mode true | false | "auto"

  - ##### isSearch boolean

  #### Returns any

  - Defined in params/paramType.ts:91

- $normalize(val: any): any

- Given an encoded string, or a decoded object, returns a decoded object

- Given an encoded string, or a decoded object, returns a decoded object

  #### Parameters

  - ##### val any

  #### Returns any

  - Defined in params/paramType.ts:77

- $subPattern(): string

- #### Returns string

  - Defined in params/paramType.ts:67

- decode(val: string, key?: string): any

- Decodes a parameter value string (from URL string or transition param) to a custom/native value.

- Decodes a parameter value string (from URL string or transition param) to a custom/native value.

  For example, if your type decodes to an array of ints, then decode the string as an array of ints here:

      decode: (str) => str.split("-").map(str => parseInt(str, 10))

  Note: in general, encode and decode should be symmetrical. That is, `encode(decode(str)) === str`

  #### Parameters

  - ##### val string

  - ##### key: Optional string

  #### Returns any

  :

  a custom representation of the URL parameter value.

  Implementation of ParamTypeDefinition.decode

  - Defined in params/paramType.ts:62

- encode(val: any, key?: string): string | string[]

- Encodes a custom/native type value to a string that can be embedded in a URL.

- Encodes a custom/native type value to a string that can be embedded in a URL.

  Note that the return value does not need to be URL-safe (i.e. passed through `encodeURIComponent()`). It only needs to be a representation of `val` that has been encoded as a string.

  For example, if your custom type decodes to an array of ints, then encode the array of ints to a string here:

      encode: (intarray) => intarray.join("-")

  Note: in general, encode and decode should be symmetrical. That is, `encode(decode(str)) === str`

  #### Parameters

  - ##### val any

  - ##### key: Optional string

  #### Returns string | string[]

  :

  a string representation of `val` that can be encoded in a URL.

  Implementation of ParamTypeDefinition.encode

  - Defined in params/paramType.ts:60

- equals(a: any, b: any): boolean

- Determines whether two decoded values are equivalent.

- Determines whether two decoded values are equivalent.

  For example, if your type decodes to an array of ints, then check if the arrays are equal:

      equals: (a, b) => a.length === b.length && a.reduce((acc, x, idx) => acc && x === b[idx], true)

  #### Parameters

  - ##### a any

  - ##### b any

  #### Returns boolean

  :

  `true` if the values are equivalent/equal, otherwise `false`.

  Implementation of ParamTypeDefinition.equals

  - Defined in params/paramType.ts:64

- is(val: any, key?: string): boolean

- Tests if some object type is compatible with this parameter type

- Tests if some object type is compatible with this parameter type

  Detects whether some value is of this particular type. Accepts a decoded value and determines whether it matches this `ParamType` object.

  If your custom type encodes the parameter to a specific type, check for that type here. For example, if your custom type decodes the URL parameter value as an array of ints, return true if the input is an array of ints:

      is: (val) => Array.isArray(val) && array.reduce((acc, x) => acc && parseInt(val, 10) === val, true)

  If your type decodes the URL parameter value to a custom string, check that the string matches the pattern (don't use an arrow fn if you need `this`): `function (val) { return !!this.pattern.exec(val) }`

  Note: This method is not used to check if the URL matches. It's used to check if a decoded value is this type. Use pattern to check the encoded value in the URL.

  #### Parameters

  - ##### val any

  - ##### key: Optional string

  #### Returns boolean

  :

  `true` if the value matches the type, otherwise `false`.

  Implementation of ParamTypeDefinition.is

  - Defined in params/paramType.ts:58

- toString(): string

- #### Returns string

  - Defined in params/paramType.ts:72

Generated using TypeDoc