Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Allow $anchorScroll to have a numeric input #14680

Closed
@samuelfernandez

Description

@samuelfernandez

Do you want to request a feature or report a bug?
Request a feature

What is the current behavior?
Now $anchorScroll expects the parameter to be a string. If a number is passed, it won't work. This can lead to a confusing situation like:
<div id="7">
$anchorScroll(7); won't work

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
http://plnkr.co/edit/CtQeFVTxgEGtFkgaTAnE?p=preview

What is the expected behavior?
If a number is provided, cast it

What is the motivation / use case for changing the behavior?
Having html elements with a numeric id

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Latest version

Other information (e.g. stacktraces, related issues, suggestions how to fix)
In angular.js/src/ng/anchorScroll.js line 240 change it to:
hash = hash ? String(hash) : $location.hash();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions