I am trying to define a single state with an optional integer route parameter.
I have defined the following state in my application
$stateProvider.state('configuration', {
stateUrl: '/configuration/{id:int}',
template: '<div></div>'
});
This is working for all routes that have an id e.g. /configuration/1
, but it does not
work for routes without the id e.g. /configuration/
.
If I drop the type definition, like the below, then routes work with or without the id at the end but I end up with a string
id rather than a number
.
$stateProvider.state('configuration', {
stateUrl: '/configuration/:id',
template: '<div></div>'
});
Is it possible to define an optional typed route parameter?