Mike Pateras
Mike Pateras

Reputation: 15015

AngularJS - How can I change just one routeParam and redirect?

I've got a route that looks like this:

/Route/:Param1/:Param2/:Param3

In my controller, I'd like to modify one of those routes and then redirect to that. So if my route is this:

/Breakfast/:Eggs/:Bacon/:Cereal

I'd like to easily route to:

/Breakfast/:Eggs/:Waffles/:Cereal

without manually rebuilding the route. Is there a way that I can just do something like this:

$routeParams.Param2 = "Waffles";
$location.path($route);

Upvotes: 3

Views: 749

Answers (1)

alx
alx

Reputation: 2367

Actually, following up my comment above, here is working sample: http://jsbin.com/owiful/1/edit. Service code needs some checks, of course, but it works as it is now.

Upvotes: 2

Related Questions