# Class ParamType

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);

- Defined in router/params/param-type.js:26

#####
Index

### Constructors

constructor

### Properties

inherit
name
pattern

### Methods

$asArray
$normalize
$subPattern
decode
encode
equals
is
toString

##
Constructors

### constructor

- new ParamType(def): ParamType

- #### Parameters

  - def: any

    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 router/params/param-type.js:32

##
Properties

### inherit

inherit: boolean

- Defined in router/params/param-type.js:34

### name

name: any

- Defined in router/params/param-type.js:36

### pattern

pattern: RegExp

- Defined in router/params/param-type.js:33

##
Methods

### $asArray

- $asArray(mode, isSearch): ArrayType

- 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: any
  - isSearch: any

  #### Returns ArrayType

  - Defined in router/params/param-type.js:73

### $normalize

- $normalize(val): any

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

  #### Parameters

  - val: any

  #### Returns any

  - Defined in router/params/param-type.js:60

### $subPattern

- $subPattern(): string

- #### Returns string

  - Defined in router/params/param-type.js:52

### decode

- decode(val): any

- #### Parameters

  - val: any

  #### Returns any

  - Defined in router/params/param-type.js:46

### encode

- encode(val): any

- #### Parameters

  - val: any

  #### Returns any

  - Defined in router/params/param-type.js:43

### equals

- equals(a, b): boolean

- #### Parameters

  - a: any
  - b: any

  #### Returns boolean

  - Defined in router/params/param-type.js:49

### is

- is(val): boolean

- #### Parameters

  - val: any

  #### Returns boolean

  - Defined in router/params/param-type.js:40

### toString

- toString(): string

- #### Returns string

  - Defined in router/params/param-type.js:56