-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$anchorScroll breaks anchor links with html5mode enabled #14315
Comments
It's not clear to me what you mean by "broken" and "navigation does not work" ? |
@gkalpak I would expect clicking on a link to navigate to a new page. This does not happen. All that happens is that the location bar changes. |
@lookfirst, I was able to reproduce the behavior here (I think). Why does it happen with When Angular instantiates your controller (which depends on As you can see in the updated plnkr, the same "issue" happens without What can I do ? If you don't want $location.html5Mode({
enabled: true,
rewriteLinks: false
}); All that said, the fact that |
I'd just be happy with some documentation around this. =) I had to spend quite a few hours figuring out the problem and hopefully anyone else who comes across this will find this issue as I couldn't find anything else like it. Thanks for investigating it further and providing the plunkrs, you definitely reproduced it. |
On a related note, I just found out that $location.search() returns no data if I pass a url in with a query string and html5Mode isn't enabled. So I used enabled: true and rewriteLinks: false and things are working for me now. |
@lookfirst, that is expected behavior. In hashbang mode, the part after the first
|
I think your example in hashbang is wrong. You've included two #'s.... Even still, the expected behavior seems wrong. I expect $location.search() to give me the data within the query string (the part after the ?) regardless of whether it is hashbang mode or html5 mode. Short of parsing the entire url myself, there is no other way of getting this data and I think that the location service should do that. |
@lookfirst, my example is corrent. In the default hashbang mode, the part after the first The $location section of the Developer Guide is quite illustrative. |
What a mess. 😢 |
Closing this as you were able to make things work for you (by setting |
I boiled this problem down to a very simple test case included below. Apologies if this has been reported before, but I did search around first for this.
Just by simply injecting
$anchorScroll
and not even calling it anywhere in the code, all anchor href's are broken. The value in the location bar changes, but navigation to the new link does not work.Disabling html5Mode works.
The text was updated successfully, but these errors were encountered: