-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngRoute): add method for changing url params #8358
feat(ngRoute): add method for changing url params #8358
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
Add a $route#update method for changing the current route parameters without having to build a URL and call $location#path. Useful for apps with a structure involving programmatically moving between pages on the current route, but with different :param values.
* | ||
* @param {Object} newParams mapping of URL parameter names to values | ||
*/ | ||
update: function(newParams) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call it updateParams
?
this looks like a nice feature. please address the changes I requested. thanks! |
This ensures that parameters are matched to the correct value when being updated.
Adds a check to ensure the $location.path() changes to an expected URL when the route changes.
Change the name of the method to make clearer its purpose.
Better to use angular methods than my clunky code.
Awesome; I pushed up a bunch of changes as you requested. Hadn't seen |
I accidentally added the updateParams tests inside of the tests for `reloadOnSearch` - This commit extracts them to their own describe block.
Moved the tests around (I put them under an unrelated test, they're in the right place now). Not planning on making any changes past this point, unless you need me to :) |
Hate to be that guy - but any idea when this will get reviewed? :) |
@NotBobTheBuilder - at 11 days your PR is doing very well! We have merged some PRs after almost 12 months! Looks like it is in the milestone for the release this week so chances are it will be reviewed and merged soon |
Cool! I had no idea what to expect - there's loads of docs on filing PRs and code quality, but nothing that I can find on what happens after the ball leaves my court :)
|
I'll be taking a look at this this week. One comment from @IgorMinar was that he's not sure the best way to handle updating query params with this API. One idea is to assume that property keys which aren't found in the path config should be set as query params. |
I would agree; that's the default behaviour of $resource so it makes sense here too. I haven't tried doing it though, I'll write some tests for it. |
I added a test and implemented the query param updating in #8601. |
Merged 77a1acc Thank you! |
Request Type: feature
How to reproduce:
Component(s): ngRoute
Impact: medium
Complexity: small
This issue is related to:
Detailed Description:
Add a
$route#update
method for changing the current routeparameters without having to manually build a URL and call
$location#path
.Useful for apps with a structure involving programmatically moving
between pages on the same route, but with different
:param
values.
Other Comments: