Monday, 6 June 2016

location - AngularJS - Best way to update $route parameter

I have several routes that are different, but contain similar parameters.


Example:



when '/user/:accountId/charts/:chartType', controller:ChartsController
when '/manager/:accountId/charts/:chartType', controller:ChartsController
when '/whatever/pathy/paththingy/charts/:chartType', controller:ChartsController


Notice all three views use the same Charts Controller to control the view. Its a fairly generic controller but it needs toggle between available chartTypes... while keeping the rest of the route.

Example: (THIS DOESN'T WORK)




if my currrent url is '/user/001/charts/comparison'
Then I call something like:
$route.current.params.chartType = 'newChart';
$route.reload(); // or soemthing similar?
I want the url to become '/user/001/charts/newChart'


Does anyone have any idea how to easily update parameters of a route without completely re-typeing or rebuilding the route path?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...