AngularJS 1.2.0 (but lower versions have the same problem)
I have a web app with some widgets and want to save their state into URL.
I do this now with $location.hash('param1=1¶m2=678')
command. But I get url like: domain.com/##param1=1¶m2=678
It works ok, I can restore state of my app. One problem I have with that is when someone click such a link in, for example, mail app, their browser encodes one of hashes with /23 and so my app goes wrong. How can i solve this? Thanks
Here is plunk: http://plnkr.co/edit/VVjEUzROou6hu8B8sURa?p=preview You need open it in new window to able to test hashes
for standard hash locations in angular, you use
location.path("myappstate/1");
as angular is set up to think of first hash state as the primary url or path for the app. The location.hash() setups a secondary hash on the primary hash state (path)
This is not the best answer, but you could try to inject $locationProvider and set:
$locationProvider.html5Mode(true);
That way angular runs in HTML5 mode and it does not use hashbangs. I recommend this SO question for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With