-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Weird Interaction with $location.hash() and Chrome/Firefox #10659
Comments
Hi, |
I'm using 1.3.6 |
|
Do I need to use html5mode() to use anchors? |
No, it is disable by default angular append |
We've also encounterd this issue, with the latest 1.3.8 have you changed the default from "##" to "#/" ? anyhow the latest update as a small revision update, did something major. |
@petebacondarwin this sounds like it is related to the changes we made for the hash-handling, @bobber205 are you using any kind of routing at all, or are you using the hash simply for scrolling? Also, could you post a reproduction? |
Simply for scrolling. We're using anchorScroll() afterwards (made sure that Will post repo in a bit On Wed, Jan 14, 2015 at 12:43 PM, Narretz notifications@github.com wrote:
Buoyancy and displacement float my boat. |
Not able to produce a example on plunker because it keeps messing with the url/url is not handled in standard way. Without setting up my own hosting, do you guys know of another place I could demo this? |
Code so far: <body ng-controller="MainCtrl">
<a id="top">THIS IS THE TOP</a>
<br/>
<br/>
<br/>
<br/>
<a id="bottom"></a>
BOTTOM
</body> app.controller('MainCtrl', function($scope, $location, $anchorScroll, $timeout) {
$timeout(function () {
$location.hash("bottom");
$anchorScroll();
},1000);
}); |
So the simple workaround for this is to actually provide a See this example: <!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body ng-app="app" ng-controller="MainCtrl">
<a id="top">THIS IS THE TOP</a>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<a id="bottom"></a>
BOTTOM
</body>
<script src="angular.js"></script>
<script type="text/javascript">
angular.module('app', [])
.config(function($locationProvider) {
$locationProvider.hashPrefix('!');
})
.controller('MainCtrl', function($scope, $location, $anchorScroll, $timeout) {
$timeout(function () {
console.log("scrolling!");
$location.hash("bottom");
debugger;
$anchorScroll();
},1000);
});
</script>
</body>
</html> |
We ought not to have to do this and it appears that we didn't previously. So this is a regression that needs fixing. @Narretz do you have any cycles to take a look? |
The above workaround does work, just confirmed locally in Chrome latest stable. However, if I put do I also just noticed that without any use of
Seems related as when I put in
|
It's not recommended to use @petebacondarwin I can take a look next week |
@Narretz good to know, thanks! 💃 sticking with ! for now. Is |
I think this is actually a duplicate of #8675 |
When I enter the following into Chrome
it turns into
This also happens when just running
$location.hash("top")
without any hashes in the URL.This causes
$location.hash()
to be""
. I need this check because if I do$location.hash("top")
in any repeated function I get#top#top
. I have a simple "is it already'top'
if check but since chrome messes with the url, it's always blank.makes the url fwiw
Any ideas of a work around?
The text was updated successfully, but these errors were encountered: