Remove Facebook OAuth hash with Angular JS
angularjs, javascript
Solution
Similar to how the search property needs to begin with ?, the hash property should begin with #.
Instead of setting location.hash equal to an empty string, set it to '#'.
location.hash = '#';
P.S.
You might be getting down votes due to this
While we're not using hash-based navigation, it looks annoying and I'd like to get rid of it.
Although I have no qualms about this, a question is a question regardless of the reason, some might find it a waste of time since the only perceived reason is that you find it annoying.
Problem
Facebook likes to add `#_=_` to the end of the OAuth callback URL we give it. While we're not using hash-based navigation, it looks annoying and I'd like to get rid of it. `location.hash = '';` causes an infinite loop in `$watch` (this also happens with `$window.location.hash = '';`). The Angular way of `$location.hash('');` changes nothing. `$location.path('');` gets us part of the way there, resulting in `/#/` being appended to our url. I've also played around with `$locationProvider.html5Mode` and received nothing but errors. (`Error: [$injector:unpr] Unknown provider: $locationProviderProvider <- $locationProvider `) though this may be my own fault. How can I remove the OAuth hash without error?