I've been working on a large Angular app for almost a year now and I'm stuck trying to do what I expected to be trivial.
Here are two routes I have with params (shortened for brevity):
/a/:id
/a/:id/b
Let's say the user is at /a/1 and the query string is modified, for example:
/#/a/1?foo=123&bar=456
I want to have a link on the page that directs the user to the second route /a/1/b while maintaining the query string, so the end result is a redirection to:
/#/a/1/b?foo=123&bar=456
I am using Angular 1.2 and the new ngRoute module.
What is the best way to achieve this behavior?
Edit:
I should mention I have a working solution right now that seems terrible to me. The link is bound to an ng-click handler which is essentially the following:
$scope.navigateToBClick = function() {
var path = $location.path() + '/b',
search = $location.search();
$location.url(path + '?' + $.param(search));
};
$locationProvider.html5Mode = false. I imagine if we resolve one problem, the other will be trivial. Also, my links are in<a>tags. I'm wondering if this is part of the issue.