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

Commit 2a5af50

Browse files
committed
docs($location): clarify guide regarding link handling
The trick with setting `<base href=".">` 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
1 parent 9bedeb3 commit 2a5af50

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/content/guide/$location.ngdoc

+11-11
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ facilitate the browser URL change and history management.
211211
## Hashbang mode (default mode)
212212

213213
In this mode, `$location` uses Hashbang URLs in all browsers.
214+
Angular also does not intercept and rewrite links in this mode. I.e. links work
215+
as expected and also perform full page reloads when other parts of the url
216+
than the hash fragment was changed.
217+
214218

215219
### Example
216220

@@ -250,6 +254,10 @@ having to worry about whether the browser displaying your app supports the histo
250254
- Opening a regular URL in a legacy browser -> redirects to a hashbang URL
251255
- Opening hashbang URL in a modern browser -> rewrites to a regular URL
252256

257+
Note that in this mode, Angular intercepts all links (subject to the "Html link rewriting" rules below)
258+
and updates the url in a way that never performs a full page reload.
259+
260+
253261
### Example
254262

255263
```js
@@ -298,8 +306,8 @@ history API or not; the `$location` service makes this transparent to you.
298306

299307
### Html link rewriting
300308

301-
When you use HTML5 history API mode, you will need different links in different browsers, but all you
302-
have to do is specify regular URL links, such as: `<a href="/some?foo=bar">link</a>`
309+
When you use HTML5 history API mode, you will not need special hashbang links. All you have to do
310+
is specify regular URL links, such as: `<a href="/some?foo=bar">link</a>`
303311

304312
When a user clicks on this link,
305313

@@ -314,17 +322,9 @@ reload to the original link.
314322
Example: `<a href="/ext/link?a=b" target="_self">link</a>`
315323
- Absolute links that go to a different domain<br>
316324
Example: `<a href="http://angularjs.org/">link</a>`
317-
- Links starting with '/' that lead to a different base path when base is defined<br>
325+
- Links starting with '/' that lead to a different base path<br>
318326
Example: `<a href="/not-my-base/link">link</a>`
319327

320-
When running Angular in the root of a domain, along side perhaps a normal application in the same
321-
directory, the "otherwise" route handler will try to handle all the URLs, including ones that map
322-
to static files.
323-
324-
To prevent this, you can set your base href for the app to `<base href=".">` and then prefix links
325-
to URLs that should be handled with `.`. Now, links to locations, which are not to be routed by Angular,
326-
are not prefixed with `.` and will not be intercepted by the `otherwise` rule in your `$routeProvider`.
327-
328328

329329
### Relative links
330330

0 commit comments

Comments
 (0)