-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Allow $anchorScroll.scroll() independent of location.hash #4568
Comments
I too, would appreciate this. I ran into the problem, where i had multiple hashes in my url, which made the $anchorScroll to freak out. |
@hasdavidc why was this closed without any real answer to the question? |
+1, would like to see this implemented. |
@hasdavidc : Why did you close the issue ? (Just being curious.) It seems a reasonable feature request (and not very difficult to implement). |
👍 |
@fabdrol looks like the original issue author closed it |
@IgorMinar Yep. Figured reopening was easier than making another issue. |
Add support for `hash` being explicitly passed as parameter to `$anchorScroll` and fall back to `$location.hash()` otherwise. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
…ation.hash()` Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted, the value of `$location.hash()` will be used instead. Closes angular#4568
Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted or is not a string, the value of `$location.hash()` will be used instead. Closes angular#4568
Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted or is not a string, the value of `$location.hash()` will be used instead. Closes angular#4568
Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted or is not a string, the value of `$location.hash()` will be used instead. Closes angular#4568
Do we have any solution for this..?? |
This functionality is already available since recently (since v1.4.0-rc.0 iirc). |
@gkalpak, can I have any ref link where can I check more about it... plz.. |
@gkalpak, In the docs, it clearly specified, "set the $location.hash to |
@siva3378, are you viewing an older version of the docs ? (Like I said, the feature was only recently added). In the latest docs (linked above) it mentions clearly:
And in Usage and Arguments sections:
|
@gkalpak Is there any (plunker) example for the usage of $anchorScroll independently of location.hash? Didn't get it to work as expected. |
This works for me: $rootScope.$on('$routeChangeSuccess', function(event) {
var old = $location.hash();
$location.hash('my-new-hash');
$anchorScroll();
$location.hash(old);
}); |
@s134319: Here is a working demo. Basically, all you got to do is call |
Add an optional argument to `$anchorScroll()` to enable scrolling to an anchor element different than that related to the current value of `$location.hash()`. If the argument is omitted or is not a string, the value of `$location.hash()` will be used instead. Closes angular#4568 Closes angular#9596
@rebelliard : This is not ideal solution of temporary putting hash and then scroll to that hash and again changing to old hash to just to stay as it is in address bar. IF you put temporary hash and you are running SPA with router which is most likely the case, then you will get immediately redirected to error page as all good SPA website make redirection to page not found kind page for invalid hash. |
@vippatel90, (just in case you missed it) there is a simpler, safer alternative (see #4568 (comment)). |
I'm wondering if there is a specific reason $anchorScroll can only scroll to the hash location and if this could be extended to simply allow an ID to be passed in to the scroll() function to override hash.
https://github.com/angular/angular.js/blob/master/src/ng/anchorScroll.js#L72-L86
The text was updated successfully, but these errors were encountered: