I have this route
.state('mystate', {
url: '/{id}',
templateUrl: '/views/partial.html'
});
The id param should be a guid in form like this "2a542f61-5fff-4607-845d-972e6c3ad1e4". How do i add this in the url "url: '/{id:?what should i put here}'".
You can define your own type of parameter.
Here is a showcase on plunker with this solution
Then specify this type in url route expression:
You can read more on that page in docs
There is a working plunker
We can just provide regexp in the url definition:
Read more about our options for url defintion:
http://angular-ui.github.io/ui-router/site/#/api/ui.router.util.type:UrlMatcher
small snippet:
After much trial and error, I came up with:
This is based on @just-boris's answer. One key difference is
pattern
. Without this it appears that invalid GUIDs will not trigger$urlRouterProvider.otherwise()
.