A property of ParamDeclaration:
Explicitly specifies the array mode of a URL parameter
false
, the parameter value will be treated (encoded/decoded) as a single valuetrue
, the parameter value will be treated (encoded/decoded) as an array of values.auto
(for query parameters only), if multiple values for a single parameter are present
in the URL (e.g.: /foo?bar=1&bar=2&bar=3) then the values are mapped to an array (e.g.:
{ foo: [ '1', '2', '3' ] }
). However, if only one value is present (e.g.: /foo?bar=1)
then the value is treated as single value (e.g.: { foo: '1' }).If you specified a type for the parameter, the value will be treated as an array of the specified Type.
A property of ParamDeclaration:
Configures how a default parameter value is represented in the URL when the current parameter value is the same as the default value.
There are three squash settings:
false
: The parameter's default value is not squashed. It is encoded and included in the URLtrue
: The parameter's default value is omitted from the URL. If the parameter is preceeded
and followed by slashes in the state's url declaration, then one of those slashes are omitted.
This can allow for cleaner looking URLs."<arbitrary string>"
: The parameter's default value is replaced with an arbitrary
placeholder of your choice.A property of ParamDeclaration:
Specifies the Type of the parameter.
Set this property to the name of parameter's type. The type may be either one of the built in types, or a custom type that has been registered with the $urlMatcherFactory
A property of ParamDeclaration:
Specifies the default value for this parameter. This implicitly sets this parameter as optional.
When UI-Router routes to a state and no value is specified for this parameter in the URL or transition, the default value will be used instead. If value is a function, it will be injected and invoked, and the return value used.
Note: value: undefined
is treated as though no default value was specified, while value: null
is treated
as "the default value is null".
// define default values for param1 and param2
params: {
param1: {
value: "defaultValue"
},
param2: {
value: "param2Default;
}
}
If you only want to set the default value of the parameter, you may use a shorthand syntax. In the params map, instead mapping the param name to a full parameter configuration object, simply set map it to the default parameter value, e.g.:
// define a parameter's default value
params: {
param1: {
value: "defaultValue"
},
param2: {
value: "param2Default;
}
}
// shorthand default values
params: {
param1: "defaultValue",
param2: "param2Default"
}
This defines a default value for the parameter. If the parameter value is undefined
, this value will be used instead
Generated using TypeDoc
Inside a StateDeclaration.params:
A ParamDeclaration object defines how a single State Parameter should work.
var mystate = { template: '<div ui-view/>', controller: function() {} url: '/mystate/:param1', params: { param1: "index", // <-- Default value for 'param1' // (shorthand ParamDeclaration) nonUrlParam: { // <-- ParamDeclaration for 'nonUrlParam' type: "int", array: true, value: [] } } }