2

I'm trying to match 1 paramater that can have 2 kinds of values: 'current' or a number with at least 10 cyphers.

I've tried:

    url: '/history/{code:^current$|^[0-9]{10,}$}'

When I use this regexp I get my app to go to history/current, but when I reload the page it goes back to the default.

Can anyone help by saying what am I doing wrong or how could I debug that?

1 Answer 1

2

There is a working example. The state definition is:

.state('history', { 
    //url: '/history/{code:^current$|^[0-9]{10,}$}',
    url: "/history/{code:current|[0-9]{10,}}",
    templateUrl: 'tpl.html',
})

And these links should do what we expect:

Working:
<a href="#/history/current">history/current</a>
<a href="#/history/0123456789">history/0123456789</a>
<a href="#/history/1234567890123">history/1234567890123</a>

Will FAIL and fall to default:
<a href="#/history/other">history/other</a>
<a href="#/history/012345678">history/012345678</a> - 9 digits
<a href="#/history/123456789a">history/123456789a</a> - a at the end

Check it here

Sign up to request clarification or add additional context in comments.

1 Comment

Would say, that in this case, we do not have to use them... they are redundant, because the rest of the regex is saying the same...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.