@@ -305,7 +305,7 @@ history API or not; the `$location` service makes this transparent to you.
305
305
### Html link rewriting
306
306
307
307
When you use the history API mode, you will need different links in different browser, but all you
308
- have to do is specify regular URL links, such as: `< a href="/some?foo=bar"> link</a> `
308
+ have to do is specify regular URL links, such as: `< a href="/some?foo=bar"> link</a> `
309
309
310
310
When a user clicks on this link,
311
311
@@ -316,12 +316,13 @@ When a user clicks on this link,
316
316
In cases like the following, links are not rewritten; instead, the browser will perform a full page
317
317
reload to the original link.
318
318
319
- - Links with an `ngExtLink` directive<br />
320
- Example: `<a href="/ext/link?a=b" ng-ext-link>link</a>`
321
- - Links that contain `target="_blank"`<br />
322
- Example: `<a href="/ext/link?a=b" target="_blank">link</a>`
323
- - Absolute links that go to a different domain<br />
319
+ - Links that contain `target` element<br>
320
+ Example: `<a href="/ext/link?a=b" target="_self">link</a>`
321
+ - Absolute links that go to a different domain<br>
324
322
Example: `<a href="http://angularjs.org/">link</a>`
323
+ - Links starting with '/' that lead to a different base path when base is defined<br>
324
+ Example: `<a href="/not-my-base/link">link</a>`
325
+
325
326
326
327
### Server side
327
328
@@ -341,11 +342,13 @@ Applications Crawlable}.
341
342
342
343
### Relative links
343
344
344
- Be sure to check all relative links, images, scripts etc. You must use an absolute path because the
345
- path is going to be rewritten. You can use `<base href="" />` tag as well.
345
+ Be sure to check all relative links, images, scripts etc. You must either specify the url base in
346
+ the head of your main html file (`<base href="/my-base">`) or you must use absolute urls
347
+ (starting with `/`) everywhere because relative urls will be resolved to absolute urls using the
348
+ initial absolute url of the document, which is often different from the root of the application.
346
349
347
350
Running Angular apps with the History API enabled from document root is strongly encouraged as it
348
- takes care of all relative link issues. **Otherwise you have to specify <base href="" /> !**
351
+ takes care of all relative link issues.
349
352
350
353
### Sending links among different browsers
351
354
@@ -379,9 +382,9 @@ In this examples we use `<base href="/base/index.html" />`
379
382
$location.path() = {{$location.path()}}<br>
380
383
$location.search() = {{$location.search()}}<br>
381
384
$location.hash() = {{$location.hash()}}<br>
382
- <a href="/base/first?a=b">/base/first?a=b</a> |
383
- <a href="sec/ond?flag#hash">sec/ond?flag#hash</a> |
384
- <a href="/base/another?search" ng-ext-link >external</a>
385
+ <a href="http://www.host.com /base/first?a=b">/base/first?a=b</a> |
386
+ <a href="http://www.host.com/base/ sec/ond?flag#hash">sec/ond?flag#hash</a> |
387
+ <a href="/other- base/another?search">external</a>
385
388
</div>
386
389
387
390
<div id="hashbang-mode" ng-controller="HashbangCntl">
@@ -393,9 +396,9 @@ In this examples we use `<base href="/base/index.html" />`
393
396
$location.path() = {{$location.path()}}<br>
394
397
$location.search() = {{$location.search()}}<br>
395
398
$location.hash() = {{$location.hash()}}<br>
396
- <a href="/base/first?a=b">/base/first?a=b</a> |
397
- <a href="sec/ond?flag#hash">sec/ond?flag#hash</a> |
398
- <a href="/base/another?search" ng-ext-link >external</a>
399
+ <a href="http://www.host.com /base/first?a=b">/base/first?a=b</a> |
400
+ <a href="http://www.host.com/base/ sec/ond?flag#hash">sec/ond?flag#hash</a> |
401
+ <a href="/other- base/another?search">external</a>
399
402
</div>
400
403
</div>
401
404
@@ -445,7 +448,7 @@ In this examples we use `<base href="/base/index.html" />`
445
448
$compileProvider.directive('ngAddressBar', function() {
446
449
return function(scope, elm, attrs) {
447
450
var browser = browsers[attrs.browser],
448
- input = angular.element('<input type="text" / >').val(browser.url()),
451
+ input = angular.element('<input type="text">').val(browser.url()),
449
452
delay;
450
453
451
454
input.bind('keypress keyup keydown', function() {
0 commit comments