-
Notifications
You must be signed in to change notification settings - Fork 3k
Wildcard matching option for query string parameters #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ure this gets parsed from exec.
Forced locals check to fail when to.params contains an asteristk. Prepped for transition triggering on new resolve.
…equalForKeys (forces a refresh for all)
This issue address a good portion of #84 but I don't believe it covers the original intent so I've added it as a separate issue. |
I definitely need this! I need my router to be able to take any set of url parameters. |
I'm wondering if we even need this. Would it be better to just always let any amount of parameters be passed to any state and add them to $stateParams? What is the real benefit of specifying either specific (e.g. Would it be nice to just leave off parameters in the url definition and still be able to pass in whatever params you want: .state('contacts.detail', {
url: '/contacts/:id',
controller: function($stateParams){
expect($stateParams).toBe({ id:1, paramA: "hello", paramB: "world!" });
}
}) <a href="/contacts/1?paramA=hello¶mB=world!">Go to Contact 1</a> The only reason I can think that it would be good to specify params in the definition is to make supplied params required, but still allow extra params to be passed; or allow you to specify object type like |
+1000 for arbitrary url parameters! |
The problem with passing all parameters to every state is how to figure out which states need to be reloaded when any parameter changes, especially when the state that's interested in those parameters has child states. |
going through old PRs... |
@christopherthielen Nah, wildcards are a separate thing. It's still on my radar, just not super urgent. The stuff in the new |
Arbitrary query parameters is a big deal in our app which utilizes backend search faceting. It's not feasible to register the parameters on the frontend since they can change at runtime. Is there any movement on this or a workaround? |
Hi, i also needed this changes for my requirement of having dynamic query parameters being passed in the url. Is this going to be merged into master? When will i get this in the release? |
Please implement this. It would be very useful to my project. For now my only option is hardcoding field names which are defined in the backend. |
When will be this ready? |
@nathanredblur No one is working on it right now. |
I wound up patching our local version. With the patch you can use $stateProvider.state('mystate', { url: '/app/something/:query?QUERYPARAMS', This will set the QUERYPARAMS parameter to the JSON encoded query You can also do a $state.go('mystate', {query: 'something', QUERYPARAMS: to trigger a state change. It's a kludge, but it works for our needs. Patch is attached. I'm not sure how well github handles attachments, so if On Tue, Sep 15, 2015 at 12:59 PM, Nate Abele [email protected]
|
@frogomatic I don't think the patch is available from the attachment. Please could you make it available another way? Do you have a fork? |
Yes, I have a fork: https://github.com/frogomatic/ui-router The 'master' branch contains the QUERYPARAMS workaround. I applied the There's also a 1119-workaround branch which contains a partial workaround On Thu, Sep 17, 2015 at 5:55 PM, Rob Walker [email protected]
|
A) add $stateSearch & $stateHash instead of change $stateParams B) allow update state's params dynamic. As I see, this |
I know I've let this languish as the core team seemed a little against my initial attempt. If they have a suggestion for pushing this forward such as pulling in the changes from @kindy I'd be happy to help move this issue along. Any thoughts from the core team? |
I think we're OK with the wildcard query parameter as a general idea. However, internal parameter handling has had a major overhaul in 1.0, and will continue to change until 1.0 final is reached. This PR will not be compatible with that branch, and parameters in that branch are a bit of a moving target at this time. Before we'll accept a wildcard PR, we need to address the original caveat raised by ksperling back in 2013. In order to determine which states in the toPath (if any) we should "keep" or we should "reload", we must associate the raw parameters with the states they belong to, and then compare the values. We need to ensure that the wildcard query param does not interfere with mapping params to path parameters, and does not interfere with mapping query parameters to parent states, as well as to potential substates. This may be challenging, because the parameters which are associated with a state are statically computed as discrete Here are some relevant lines: Lines 23 to 26 in f8e5f67
Lines 40 to 41 in f8e5f67
|
Any update on this? I have a search system that accepts arbitrary "tag names" as params so I cant specify all params upfront in the urls. |
BTW if you want to access query params you can still inject $location and grab them through $location.search(). |
@peterjhart, Yes, but the problem is if you don't specify param names in url - the state is not being reloaded. And if memory serves me right, also ui-sref will ignore additional params when generating urls. |
@ergo ohisee. D'oh. |
This issue has been automatically marked as stale because it has not had This does not mean that the issue is invalid. Valid issues Thank you for your contributions. |
This is a wildcard matching change so that /path/:to/:foo?* is an acceptable url from the UrlMatcherFactory. If given this will match all query string parameters and pass that down to the state. This will also by default cause a reload. You can set the option in your state for reloadWild: false to disable the auto reload based on changes here.
Please feel free to comment about what else you might like to see here as this meets my needs but I'm not sure it meets all needs that I've seen moving back and forth on this issues list. I'd be happy to update this for those needs or give someone else collaborator access to this branch if needed.