Reputation: 10154
We use angular 1.5, and have our own routing mechanism (by listening to $locationChangeSuccess
event).
It works fine, but when I edit that hash part of the URL, and set it to #a/b
, it is immediately replaced with #a%2fb
(although $locaction.hash()
returns 'a\b').
Any idea why this happens, and more importantly, how it can be prevented?
At first I thought it is done be the browser, but when I add #a/b
to the URL of a simple html file in the browser, the /
remains, so I assume angular is involved here.
In my app.ts
, $locationProvider
is configured like this:
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
Upvotes: 0
Views: 369
Reputation: 10154
I looked at angular source and realized this is probably cannot be done with html enabled - hash part will always be encoded. But I did find out that the encoding used in the $location service is a custom encoding, and ':' is not encoded, so I switched from using '/' as a separator in the hash part to use ':'.
Upvotes: 0
Reputation: 480
Adding exclamation point '!' to your links should also do the job, for your case should be something like this:
<a href="#!a/b"
Upvotes: 1