-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs($location): location#hash example #10300
Conversation
The given example does not actually work in the browser. location.hash() only returs the value after a slash and a second hash.
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. |
I have signed the CLA |
CLAs look good, thanks! |
@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 Does it make sense? Would you be up to amending your comment accordingly? |
@pkozlowski-opensource To answer your question, I tested in:
Mac Yosemite
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 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! |
@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 It is perfectly fine to have 2 # in the URL - a browser will interpret Test it on your side so you don't have to blindly believe in what I'm saying here :-) |
@pkozlowski-opensource Worked with it a little bit on my site. I see what you mean now! Thanks. Update has been committed. |
The given example is slightly different then functionality. location.hash() only returns the value after a slash and a second hash.