diff --git a/src/ng/anchorScroll.js b/src/ng/anchorScroll.js index 50512b173253..77e8ded5ce37 100644 --- a/src/ng/anchorScroll.js +++ b/src/ng/anchorScroll.js @@ -238,6 +238,9 @@ function $AnchorScrollProvider() { } function scroll(hash) { + //Allow hash to be a number + if (isNumber(hash)) hash = hash.toString(); + hash = isString(hash) ? hash : $location.hash(); var elm; diff --git a/test/ng/anchorScrollSpec.js b/test/ng/anchorScrollSpec.js index 8f7e4a2c8829..22fb13608f11 100644 --- a/test/ng/anchorScrollSpec.js +++ b/test/ng/anchorScrollSpec.js @@ -260,6 +260,18 @@ describe('$anchorScroll', function() { addElements('id=top'), callAnchorScroll('top'), expectScrollingTo('id=top'))); + + + it('should scroll to element with id "7" if present, with a given hash of type number', inject( + addElements('id=7'), + callAnchorScroll(7), + expectScrollingTo('id=7'))); + + + it('should scroll to element with id "7" if present, with a given hash of type string', inject( + addElements('id=7'), + callAnchorScroll('7'), + expectScrollingTo('id=7'))); }); });