-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Added support for route parameter regular expression constraints #5923
Conversation
Added support for route parameter regular expression constraints
this is pretty cool, but it definitely needs some tests. I think these tests should be pretty easy to write. Also, it would be good if it looked a bit more like the angular-ui/ui-router regexp parameter rules, just so that there's a bit more consistency and it's easier for people to switch between them if they feel they need to. Other than that, LGTM, so put together some tests and we can probably get this into 1.3. I believe a new router is being planned, so this behaviour will probably be desirable there too, but I don't think I have the planning documents for the new router on me. |
Didn't make it into 1.3 beta, did it? :( |
+1 on adding tests and shipping this! |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
up 👍
|
or better syntax
|
I don't think curly braces are a better choice here, as Angular routing doesn't use them to embrace whole URL segments... That's .net's syntax. I proposed double colon as that's an identifier of a variable in segment so could as well serve as a separator of additional properties (like regexes). Your first suggestion of using less/greater-than characters is in my opinion also a better choice than curly braces. So all of these are arguably better, worse, usable or unusable. |
Hi, We are trying to use this new feature in our app but getting the same error as earlier. Angular is still not able to identify the regular expression differentiating a string from an integer. Can you please share some code-snippet or the correct way to pass the regex in route params? We are using angular v1.2.6 and just want this fix to work for having regex support. Thanks in advance! |
@bisdg what error are you talking about? Can you provide more information? |
Hi litera, I think the problem was in our code where the regular expression was not correct and not matching with the location url. Thanks a ton for your reply. |
Hi, thanks, |
Please Check this feature as it's really helpful |
+1 |
Why this feature has not been accepted? It's really helpful! |
Still waiting for it :( |
Still waiting on tests.... |
this is a basic feature from 2014 and is still OPEN! angular it's just not production ready by any means with the lack of so many basic features like this one (and many others than are stopping me from finishing the prototype that I was going to show to the company's architect to select ang as our new frontend framework, but right now will have to scarp it and pick react or vue because ang is more trouble than is worth) |
@chulian1819 angular.js is no longer in development if you want to use Angular then look at https://angular.io/ which is more updated and still in development. React and Vue are also good choices :). |
Adds support for route parameters with regular expression constraints:
This makes it possible to create two seemingly similar but different routes i.e.
Where parameter
:id
has numeric regular expression constraint and:name
in second route has a letter constraint. Double backslash has to be used because single one is stripped out by Javascript as it's an escape character and since "d" doesn't need escaping, it gets stripped out. We have to use double to preserve single backslashes.Route constraints work as follows: