I'm using AngularJS, and would like to process a given #hash-fragment in the address-bar. However, —and this is key— I'll not be using the hash-fragment to encode a path. But it seems AngularJS insists on interpreting it that way.
For example, when html5Mode is disabled:
- A given URL:
http://my.domain.com#my-hash - is turned into
http://my.domain.com/#/my-hash, and $location.hash()will be empty.
And when html5Mode is enabled:
- A given URL:
http://my.domain.com#my-hash - is turned into
http://my.domain.com/my-hash, and $location.hash()will still be empty.
AngularJS must be thinking: "oh, you have html5, let me remove that hash for you". How considerate…
The only way to get anything from $location.hash() is when the URL has a double hash:
- For a given URL:
http://my.domain.com##my-hash $location.hash()is finally equal to"my-hash", and- if also
$locationProvider.html5Mode(true)one of the hashes is stripped from the URL.
But I really need a simple single hash character to remain unprocessed. Is this possible?