Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
We're having a strange issue with links to our site with anchor tags.
www.site.com/page-name#anchor-id
Gets changed to
www.site.com/page-name#/anchor-id
causing the anchor not to work.
Any ideas on what would cause this?
<addTrailingSlash>false</addTrailingSlash> is already off
<addTrailingSlash>false</addTrailingSlash>
Discovered that this is due to AngularJS that is in the web app.
Yeah, ran into that myself. There is an AngularJS config value that disables that behavior.
angular.module("yourApp").config(function ($locationProvider) { $locationProvider.html5Mode({ enabled: true, rewriteLinks: fase, requireBase: false }); });
Not sure if all of those values are necessary, but that's what I set it to on one of my sites. More info here: https://docs.angularjs.org/api/ng/provider/$locationProvider
Yeah, I've tried that config for html5Mode and it wasn't helping. Thanks for the reply though.
Have you tried it with those exact three parameters? IIRC, it didn't work for me when I tried it with just rewriteLinks set to false.
rewriteLinks
You hit the nail on the head! I was so close earlier, I just didn't include the requireBase property. Thanks for the help, Nicholas!
Okay, now AngularJS is intercepting all anchor tags on the page, and none of the links work unless you add target="_self", which isn't an option...
target="_self"
Is that still the case when you set enabled to true (or to false)?
enabled
What happens when you click an anchor tag? Does the URL change? To the correct value? Does it scroll down the page (assuming that's what you want)?
Yeah with enabled: true, clicking on an a tag will update the url as expected but the navigation will not occur.
enabled: true
I had to remove $location from one of my controllers. That did it.
$location
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Umbraco 7.5 Adding / to URL after Anchor #
We're having a strange issue with links to our site with anchor tags.
Gets changed to
causing the anchor not to work.
Any ideas on what would cause this?
<addTrailingSlash>false</addTrailingSlash>
is already offDiscovered that this is due to AngularJS that is in the web app.
Yeah, ran into that myself. There is an AngularJS config value that disables that behavior.
Not sure if all of those values are necessary, but that's what I set it to on one of my sites. More info here: https://docs.angularjs.org/api/ng/provider/$locationProvider
Yeah, I've tried that config for html5Mode and it wasn't helping. Thanks for the reply though.
Have you tried it with those exact three parameters? IIRC, it didn't work for me when I tried it with just
rewriteLinks
set to false.You hit the nail on the head! I was so close earlier, I just didn't include the requireBase property. Thanks for the help, Nicholas!
Okay, now AngularJS is intercepting all anchor tags on the page, and none of the links work unless you add
target="_self"
, which isn't an option...Is that still the case when you set
enabled
to true (or to false)?What happens when you click an anchor tag? Does the URL change? To the correct value? Does it scroll down the page (assuming that's what you want)?
Yeah with
enabled: true
, clicking on an a tag will update the url as expected but the navigation will not occur.I had to remove
$location
from one of my controllers. That did it.is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion