In my app, I would like to match the url
exactly. in case the url
doesn't match exactly, I require to redirect to defualt as '`.
at present I require to test:
localhost:3000/sn=1234 or localhost:3000/sn=abc123 or localhost:3000/sn=abc123
that means, minimum the sn=
should presence with values
whether by number or alphabets or both mixed.
at present my state
looks like this:
.state('serialCreateCase', {
url: '^/sn={serialNumber}',
templateUrl:'app/createCase/create-case.html',
controller: 'createCaseController as ctrl'
})
But it works for : both localhost:3000/sn=, localhost:300/sn
- how to prevent this? and match the required value?
Thanks in advance.
You can use a regular expression qualifier for the state parameter. For example
url: '/sn={serialNumber:[a-z0-9]+}'
See https://ui-router.github.io/docs/0.3.1/#/api/ui.router.util.type:UrlMatcher
Note: I removed the ^
prefix you had on your URL. No documentation I've seen supports such a format.