4

I've been looking for a lot of references like:

AngularJS regex route for similar url to load different controller and view

AngularJS - Route - How to match star (*) as a path

These are questions 1-2 years ago. I'm using AngularJS v1.2.16 and I'd want to know if AngularJS with my version or upper already supports regex pattern in path param.

I mean. I have these two routes

$routeProvider
.when("/:color/:number", {
  templateUrl: "/view/example/index.html",
  controller: "ColorController"
})
.when("/:artist/:name", {
  templateUrl: "/view/example/index.html",
  controller: "ColorController"
});

Then, I'd like to enter a pattern to restrict a :number to be an integer number but the controller and view are the same in both cases, i.e.

$routeProvider
.when("/:color/:[0-9]", {
  templateUrl: "/view/example/index.html",
  controller: "ColorController"
});
.when("/:artist/:name", {
  templateUrl: "/view/example/index.html",
  controller: "ColorController"
});

Or something like that. Is it already possible with AngularJS $routeProvider?

I know the AngularUI Router but I'd wish to use $routeProvider if possible

Any ideas?

0

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.