Skip to content

feat($state): support URLs with #fragments in html5Mode #1855

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

Closed
wants to merge 0 commits into from
Closed

feat($state): support URLs with #fragments in html5Mode #1855

wants to merge 0 commits into from

Conversation

mismith
Copy link

@mismith mismith commented Apr 2, 2015

Allow setting the # param to update the location fragment; e.g.: ui-sref="page({name: 'name', '#': 'frag'})" or $state.go('page', {name: 'name', '#': 'frag'})

This is hoping to solve the various issues found in: #701, #1187, and #1455

@nateabele
Copy link
Contributor

Looks pretty good, thanks for putting this together. Just to be clear, what's the behavior in non-HTML5-mode? Do you just not get a fragment?

@mismith
Copy link
Author

mismith commented Apr 2, 2015

I would assume so, I haven't really thought that through. What would be best? Do browsers even let you set a URL like #!/hello/world#frag

@nateabele
Copy link
Contributor

Yeah, you can put whatever you want in the URL. I believe the $location service takes care of parsing for you. See here: https://docs.angularjs.org/api/ng/service/$location#hash

If you can amend the commit with a test that verifies that this change mimics the above behavior (you might have to break off the '#' and pass it to $location.hash() after the call to $location.url()), then I'll merge this. Thanks a lot for your work on this.

@nateabele nateabele mentioned this pull request Apr 3, 2015
@mismith
Copy link
Author

mismith commented Apr 8, 2015

So which would you prefer, that I enable this behaviour for non-html5Mode as well, or test that it has no effect when in that mode? (I would personally prefer the former, if it is indeed possible.)

@nateabele
Copy link
Contributor

I think the effect should be the same as using $location.hash(), so, you get an extra # in the URL, that the $location service parses out transparently. Does that make sense?

@mismith mismith closed this Apr 8, 2015
@nateabele
Copy link
Contributor

Again, I think you could probably just Make It Work™ by passing the params['#'] to $location.hash() instead of appending it to url.

@mismith
Copy link
Author

mismith commented Apr 8, 2015

I think the issue with that would be the order of operations? If I used .hash() in place of appending the the url, it would fire right away, no? (rather than after the state changes)

@nateabele
Copy link
Contributor

Not sure, I just assumed it would work. Anyway, if the tests pass in the new PR in both modes, good enough for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants