From d7c084f9cf646d22147a4482f96a0de632b7e222 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Wed, 3 Sep 2014 09:28:04 -0700 Subject: [PATCH] docs($location): clarify guide regarding link handling The trick with setting `` has not worked since Angular 1.2.0. It is also misleading that it talks about `$routeProvider.otherwise` which is not important in this case. Related to #8869 Closes #8908 --- docs/content/guide/$location.ngdoc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/content/guide/$location.ngdoc b/docs/content/guide/$location.ngdoc index cf7d41f57..4936c9d4b 100644 --- a/docs/content/guide/$location.ngdoc +++ b/docs/content/guide/$location.ngdoc @@ -211,6 +211,10 @@ facilitate the browser URL change and history management. ## Hashbang mode (default mode) In this mode, `$location` uses Hashbang URLs in all browsers. +Angular also does not intercept and rewrite links in this mode. I.e. links work +as expected and also perform full page reloads when other parts of the url +than the hash fragment was changed. + ### Example @@ -250,6 +254,10 @@ having to worry about whether the browser displaying your app supports the histo - Opening a regular URL in a legacy browser -> redirects to a hashbang URL - Opening hashbang URL in a modern browser -> rewrites to a regular URL +Note that in this mode, Angular intercepts all links (subject to the "Html link rewriting" rules below) +and updates the url in a way that never performs a full page reload. + + ### Example ```js @@ -298,8 +306,8 @@ history API or not; the `$location` service makes this transparent to you. ### Html link rewriting -When you use HTML5 history API mode, you will need different links in different browsers, but all you -have to do is specify regular URL links, such as: `link` +When you use HTML5 history API mode, you will not need special hashbang links. All you have to do +is specify regular URL links, such as: `link` When a user clicks on this link, @@ -314,17 +322,9 @@ reload to the original link. Example: `link` - Absolute links that go to a different domain
Example: `link` -- Links starting with '/' that lead to a different base path when base is defined
+- Links starting with '/' that lead to a different base path
Example: `link` -When running Angular in the root of a domain, along side perhaps a normal application in the same -directory, the "otherwise" route handler will try to handle all the URLs, including ones that map -to static files. - -To prevent this, you can set your base href for the app to `` and then prefix links -to URLs that should be handled with `.`. Now, links to locations, which are not to be routed by Angular, -are not prefixed with `.` and will not be intercepted by the `otherwise` rule in your `$routeProvider`. - ### Server side