-
Notifications
You must be signed in to change notification settings - Fork 3k
Using Catch All parameters with ui-sref #733
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
Comments
👍 Another solution to this could be to be able to pass an array as the parameter value in ui-sref, like so: |
URL-encoded link causes two $locationChangeStart events. |
+1 |
Encountered a similar problem like @dmitry-dedukhin. Navigating to a state that has an url like: '/someAction/{id}/*params', makes two calls to the server for the template associated with the state. |
Just wanted to add that I have the same issue with the URLs. Does anyone have a hacky workaround until someone creates a core-modification to resolve this? |
I'm not quite sure if my issue was the same as described here, but changing |
Ignore that, spoke too soon. It works as far as clicking the links in the browser works, but inspecting/copying the generated href shows it is still encoded. I still need a workaround like @Xiot suggested, although in keeping with the
|
I like the idea of basing it off of the type. |
@Xiot I think this should do it. I've set up a new type which, on encoding, splits it by |
I've hit this same issue, the fix from @lopsided works a treat. Any chance of it getting merged in @nateabele? It really does make the URLs much more pleasant |
Unfortunately, this problem got a whole lot worse with the new release. Not only do the slashes get encoded, but it looks like they get encoded mistakenly several times over rendering ui-router completely useless in this manner -.- Urgh, can anyone think of a good fix other than using someone else's branch? |
I use commas instead of slashes for this very case. |
+1 |
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. |
I currently have a n-level deep route which can consist of a variable number of segments (ie directory browser). I have the following state set up:
The transition is then navigated through an ui-sref
<a ui-sref="folders({folderPath: "folder1/folder2"})" >Link</a>
The ui-sref works fine and the location is changed to
system/folder1/folder2
however the link that shows up in the browser when you hover over it issystem/folder1%2Ffolder2
because the value is passed throughencodeURIComponent
What I am proposing is that for catch all route parameters, the value gets uri encoded, but should leave any forward slashes in, or at least have an option to make it work like that.
I can get around it by using ng-href to compose the uri, however then I lose the funtionality of ui-sref-active.
I did a quick and dirty hack of changing UrlMatcher.prototype.format to use
but that only works for the shorthand
*parameterName
syntax. The better way would probably be to keep a record of the catch-all parameters when the url format is parsed and use that to determine how to encode the value.Let me know your thoughts
The text was updated successfully, but these errors were encountered: