This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Allow $anchorScroll to have a numeric input #14680
Milestone
Comments
We could change this but in the end ids can never be numbers. They are always strings because html attribute values are always strings. |
Yes, but if a numeric id is assigned with interpolation to the html id, you need to remember that when invoking anchorScroll you should cast it. If the function could be smarter for different input formats, this could be great! |
I don't like converting anything to a string (e.g. I'm not 100% certain I would merge a PR with that change, but if anyone feels like submitting one, I'm sure we would consider it 😉 |
mrLarbi
added a commit
to mrLarbi/angular.js
that referenced
this issue
Sep 23, 2016
Ref angular#14680 Before the change : <div id="7"> $anchorScroll(7); Does not work After the change : <div id="7"> $anchorScroll(7); works
mrLarbi
added a commit
to mrLarbi/angular.js
that referenced
this issue
Sep 23, 2016
Ref angular#14680 Before the change : <div id="7"> $anchorScroll(7); Does not work After the change : <div id="7"> $anchorScroll(7); works
3 tasks
mrLarbi
added a commit
to mrLarbi/angular.js
that referenced
this issue
Sep 25, 2016
Ref angular#14680 Before the change : <div id="7"> $anchorScroll(7); Does not work After the change : <div id="7"> $anchorScroll(7); works
petebacondarwin
pushed a commit
to petebacondarwin/angular.js
that referenced
this issue
Nov 21, 2016
This allows `$anchorScroll(7)` to scroll to `<div id="7">` (although technically, the target ID is a string, not a number). Fixes angular#14680 Closes angular#15182
petebacondarwin
pushed a commit
to petebacondarwin/angular.js
that referenced
this issue
Nov 21, 2016
This allows `$anchorScroll(7)` to scroll to `<div id="7">` (although technically, the target ID is a string, not a number). Fixes angular#14680 Closes angular#15182
petebacondarwin
pushed a commit
to petebacondarwin/angular.js
that referenced
this issue
Nov 21, 2016
This allows `$anchorScroll(7)` to scroll to `<div id="7">` (although technically, the target ID is a string, not a number). Fixes angular#14680 Closes angular#15182
petebacondarwin
pushed a commit
to petebacondarwin/angular.js
that referenced
this issue
Nov 21, 2016
This allows `$anchorScroll(7)` to scroll to `<div id="7">` (although technically, the target ID is a string, not a number). Fixes angular#14680 Closes angular#15182
petebacondarwin
pushed a commit
to petebacondarwin/angular.js
that referenced
this issue
Nov 21, 2016
This allows `$anchorScroll(7)` to scroll to `<div id="7">` (although technically, the target ID is a string, not a number). Fixes angular#14680 Closes angular#15182
ellimist
pushed a commit
to ellimist/angular.js
that referenced
this issue
Mar 15, 2017
This allows `$anchorScroll(7)` to scroll to `<div id="7">` (although technically, the target ID is a string, not a number). Fixes angular#14680 Closes angular#15182
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 workIf 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();
The text was updated successfully, but these errors were encountered: