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.

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

Constructors

  • 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

Properties

inherit: boolean
name: any
pattern: RegExp

Methods

  • 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

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

    Parameters

    • val: any

    Returns any