Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

docs($location): location#hash example #10300

Closed
wants to merge 2 commits into from

Conversation

whayler1
Copy link
Contributor

@whayler1 whayler1 commented Dec 2, 2014

The given example is slightly different then functionality. location.hash() only returns the value after a slash and a second hash.

The given example does not actually work in the browser. location.hash() only returs the value after a slash and a second hash.
@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

@whayler1
Copy link
Contributor Author

whayler1 commented Dec 2, 2014

I have signed the CLA

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Dec 2, 2014
@pkozlowski-opensource
Copy link
Member

@whayler1 I think that the example in the doc refers to a URL in html5 mode. So the initial URL and which part gets returned will actually depend on the url mode used (html5 / hashbang). How / in which browser did you test it?

But yeh, I can see that other examples are using hashbang mode so we should be consistent in the examples. So it should rather be something like // given url http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue.

Does it make sense? Would you be up to amending your comment accordingly?

@whayler1
Copy link
Contributor Author

whayler1 commented Dec 2, 2014

@pkozlowski-opensource To answer your question, I tested in:
PC Windows 7

  • IE8
  • IE9

Mac Yosemite

  • FF (latest)
  • Safari (latest)
  • Chrome (latest)

And I am running angular 1.2.24

In all cases the value of $location.hash() for "#someVal" is nothing. It is true you can have as many hashbang routes if you wish between the first hashbang and second hash. However it will only return the value after the second hash. i.e.

// http://some-site.com#/#someVal
$location.hash();
// => someVal

or

// http://some-site.com#/some/hash/bang#someVal
$location.hash();
// => someVal

The only issue I see with your example is that the querystring is after the initial hashbang, which i think would nullify it. I would alter it to be something like http://example.com/?foo=bar&baz=xoxo#/some/path#hashValue.

Let me know your thoughts and I am happy to test more extensively to double-verify all this if your not 100% on the above. Thanks!

@pkozlowski-opensource
Copy link
Member

@whayler1 ok, so the browsers you've tested with don't support HTML5 mode thus your testing results.

Regarding the example itself: all the examples are using this path http://example.com/#/some/path?foo=bar&baz=xoxo which is a path in the hashbang mode. So let's use it here as well with an additional hash, that is: http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue

It is perfectly fine to have 2 # in the URL - a browser will interpret #/some/path?foo=bar&baz=xoxo#hashValue as a hash while AngularJS will interpret #/some/path?foo=bar&baz=xoxo#hashValue as a path that happens to have hashValue as a hash part.

Test it on your side so you don't have to blindly believe in what I'm saying here :-)

@pkozlowski-opensource pkozlowski-opensource self-assigned this Dec 3, 2014
@whayler1
Copy link
Contributor Author

whayler1 commented Dec 3, 2014

@pkozlowski-opensource Worked with it a little bit on my site. I see what you mean now! Thanks. Update has been committed.

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

Successfully merging this pull request may close these issues.

3 participants