fix($anchorScroll): don't scroll to top when initializing and location hash is empty

Closes #8848
Closes #9393
This commit is contained in:
Igor Minar
2014-10-02 09:41:47 -07:00
parent df1a00b11a
commit d5445c601f
2 changed files with 21 additions and 1 deletions

View File

@@ -94,7 +94,10 @@ function $AnchorScrollProvider() {
// (no url change, no $location.hash() change), browser native does scroll
if (autoScrollingEnabled) {
$rootScope.$watch(function autoScrollWatch() {return $location.hash();},
function autoScrollWatchAction() {
function autoScrollWatchAction(newVal, oldVal) {
// skip the initial scroll if $location.hash is empty
if (newVal === oldVal && newVal === '') return;
$rootScope.$evalAsync(scroll);
});
}