Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat($route): regexp support for $route params #972

Closed
wants to merge 1 commit into from

Conversation

petrovalex
Copy link
Contributor

Commit related to the issue #918

  • regex for the route is constructed once and then reused
  • allows provide regex expressions for params in the constraints object:
    $routeProvider.when('/user/:id/:age', {template:'user.html'}, {id:"[0-9]", age:"[0-9]"})
  • list of values is supported using regular expression:
    $routeProvider.when('/some/:param', {template:'foo.html'}, {param:"one|two|tree"});
  • supports predefined types for paramsters (int, float, bool, string):
    $routeProvider.when('/some/:param', {template:'foo.html'}, {param:"float"});
    $routeParams.param will be typeof number
  • predefined types can be extended, bu extending $routeProvider.shortcut object

Thanks for your contribution! In order for us to be able to accept it, we ask you to sign our CLA (contributor's license agreement).

CLA is important for us to be able to avoid legal troubles down the road.

For individuals (a simple click-through form):
http://code.google.com/legal/individual-cla-v1.0.html

For corporations (print, sign and scan+email, fax or mail):
http://code.google.com/legal/corporate-cla-v1.0.html

@freewind
Copy link

freewind commented Jul 6, 2012

Hope angularjs team can review/merge this pull request, I need this feature very much

@mhevery
Copy link
Contributor

mhevery commented Aug 31, 2012

Copy & Paste this into PRs: "Thanks for your contribution! In order for us to be able to accept it, we ask you to sign our CLA (contributor's license agreement).

CLA is important for us to be able to avoid legal troubles down the road.

For individuals (a simple click-through form):
http://code.google.com/legal/individual-cla-v1.0.html

For corporations (print, sign and scan+email, fax or mail):
http://code.google.com/legal/corporate-cla-v1.0.html"

@ghost ghost assigned mhevery Sep 4, 2012
@mhevery
Copy link
Contributor

mhevery commented Sep 4, 2012

Thanks for the PR, and very sorry about the delay in getting to it. Unfortunately this feature is not yet done. There are few use cases outlined in comments which do not work, and the PR is missing documentation. Could you update it and rebase to master and we will have another look. We promise not to take 3 months again. Again sorry about the delay.

I understand this may not be a priority for you, so I am going to close this request so that it does not show up in our list. Once you update the changes requested please reopen the request.

@mhevery mhevery closed this Sep 4, 2012
@rzajac
Copy link

rzajac commented Jan 21, 2013

Any news about this patch? I really would like to see regexp routes in AngularJS.

@chanpory
Copy link

Any updates? Really want this feature!

@laurent-le-graverend
Copy link

I am a bit lost, it has been pushed in the master or in the v1?

@pkozlowski-opensource
Copy link
Member

@laurent-le-graverend it didn't land in any branch, see this comment:
#972 (comment)

@leostera
Copy link
Contributor

leostera commented May 3, 2013

👍 to this feature. Extremely helpful to define the routes using regexes, even more so to be able to access the compiled regexes later.

@samstr
Copy link

samstr commented Jun 4, 2013

👍

I would like to allow routes with a variable amount of subcategories

/category1/category2/category/3 where category 2 and 3 are optional but parsed & their resources resolved if they exist.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants