-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($location): fix handling of hash fragment links #10190
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
CLA done |
CLAs look good, thanks! |
This commit adds a new `fixHashFragmentLinks` method to `$locationProvider`. This method fixes incorrect rewriting of hash fragment links. In order to use in your project, you need to enable the new behavior: ```js myApp.config(function($locationProvider) { $locationProvider.fixHashFragmentLinks(true); }); ``` In addition, you need to inject the `$anchorScroll` service to one of your controllers/services, to enable automatic anchor scrolling. Closes angular#8675
6172383
to
a1f8378
Compare
Seems like the build has errored - is there any way to run it again? |
loadFixture("ng/location/hashFragmentScrolling").andWaitForAngular(); | ||
}); | ||
|
||
it('should scroll to the element whose id appears in the hash part of the link', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is causing an error in Travis (and looks like it's causing all subsequent tests to fail).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this reproduce? A similar line already exists in this test, so I don't see a reason why it would break here...
Ahalan @urish - I restarted your build and it is passing now. Next time you can do it yourself simply by doing |
Thanks @shahata ! |
This is not really a sensible solution, since it then prevents users from using routing. Instead a better workaround is just to provide a hash prefix, such as |
This commit adds a new
fixHashFragmentLinks
method to$locationProvider
. This method fixes incorrect rewriting of hash fragment links. In order to use in your project, you need to enable the new behavior:In addition, you need to inject the
$anchorScroll
service to one of your controllers/services, to enable automatic anchor scrolling.Closes #8675