Optionaldynamic
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
Optionalinherit
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.
$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]]
Optionalpattern
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:
(?: ))
/^foo$/
Optionalraw
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
The URL parameter value to decode.
Optionalkey:
string
The name of the parameter in which
val is stored. Can be used for
meta-programming of
ParamType objects.
a custom representation of the URL parameter value.
Encodes a built-in/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.
Note: in general, [[encode]] and [[decode]] should be
symmetrical. That is,
encode(decode(str)) === str
The value to encode.
Optionalkey:
string
The name of the parameter in which
val is stored. Can be used for
meta-programming of
ParamType objects.
a string representation of val that can be
encoded in a URL.
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)
A value to compare against.
A value to compare against.
true if the values are equivalent/equal,
otherwise false.
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.
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.
The value to check.
Optionalkey:
string
If the type check is happening in the context of a
specific URL parameter, this is the name of the
parameter in which val is stored. Can
be used for meta-programming of
ParamType objects.
true if the value matches the type, otherwise
false.
Describes a built-in [[ParamType]].
Parameter values are parsed from the URL as strings. Typed parameter definitions control how built-in parameter values are encoded to the URL and decoded from the URL. The router always provides decoded parameter values to the user (from methods such as [[Transition.params]]).
For example, if a state has a url of
/foo/{fooId:int}(thefooIdparameter is of theintParamType) and if the browser is at/foo/123, then the 123 is parsed as an integer: