diff --git a/js/ext/angular/src/service/decorators/location.js b/js/ext/angular/src/service/decorators/location.js index ebd23b4c57..53d25acc53 100644 --- a/js/ext/angular/src/service/decorators/location.js +++ b/js/ext/angular/src/service/decorators/location.js @@ -4,25 +4,25 @@ angular.module('ionic.decorator.location', []) * @private */ .config(['$provide', function($provide) { + function $LocationDecorator($location, $timeout) { + + $location.__hash = $location.hash; + //Fix: when window.location.hash is set, the scrollable area + //found nearest to body's scrollTop is set to scroll to an element + //with that ID. + $location.hash = function(value) { + if (angular.isDefined(value)) { + $timeout(function() { + var scroll = document.querySelector('.scroll-content'); + if (scroll) + scroll.scrollTop = 0; + }, 0, false); + } + return $location.__hash(value); + }; + + return $location; + } + $provide.decorator('$location', ['$delegate', '$timeout', $LocationDecorator]); }]); - -function $LocationDecorator($location, $timeout) { - - $location.__hash = $location.hash; - //Fix: when window.location.hash is set, the scrollable area - //found nearest to body's scrollTop is set to scroll to an element - //with that ID. - $location.hash = function(value) { - if (angular.isDefined(value)) { - $timeout(function() { - var scroll = document.querySelector('.scroll-content'); - if (scroll) - scroll.scrollTop = 0; - }, 0, false); - } - return $location.__hash(value); - }; - - return $location; -}