25

I was reading the angular documentation and I came across this option:

From the ContainerComponent, you should be able to navigate to AComponent using the following routerLink, but it will not work if relativeLinkResolution is set to 'legacy':

<a [routerLink]="['./a']">Link to A</a>

However, this will work:

<a [routerLink]="['../a']">Link to A</a>

In other words, you're required to use ../ rather than ./ when the relative link resolution is set to 'legacy'.

From: https://angular.io/api/router/ExtraOptions#relativeLinkResolution

But my question is what is the difference between legacy and corrected? and what is the use of the legacy option, what use I can have by using ../ instead of ./ ?

Napo
  • 533
  • 1
  • 5
  • 13
  • 8
    `legacy` (how it used to be) = two dots to refer to same level. `corrected` (now default in Angular 11) = using a single dot to refer to same level. – Markus Pscheidt Feb 11 '21 at 11:01
  • 4
    Legacy is just to keep your app backward compatible if you rely on previous erroneous behavior – ToM Feb 23 '21 at 12:59

1 Answers1

15

As Markus Pscheidt said:

legacy (how it used to be) = two dots to refer to same level.

corrected (now default in Angular 11) = using a single dot to refer to same level.

Napo
  • 533
  • 1
  • 5
  • 13
  • 4
    How is RelativeLinkResolution changed in Angular15?? Since same is not available as part of ExtraOptions – Vishesh Apr 24 '23 at 15:36
  • @Vishesh, refer https://stackoverflow.com/questions/76087462/relativelinkresolution-not-working-in-angular-15-but-it-used-to-work-in-11 – Srk95 Jun 08 '23 at 11:38
  • @Srk95 Sorry did not understand what you are referring to here. However, that question post has been answered by me only. Thanks – Vishesh Jun 09 '23 at 01:08