Is it possible to do something like:
<ul>
<li *ngFor="let language of languages">
<a [routerLink]="['#' + language]">{{language}}</a>
</li>
</ul>
or
<ul>
<li *ngFor="let language of languages">
<a fragment="language">{{language}}</a>
</li>
</ul>
to keep the same url
and add #en
, #es
or #fr
depending on what language
value is? I can't make it work.
You can try something like this:
<ul>
<li *ngFor="let language of languages">
<a [routerLink]="" fragment="language">{{language}}</a>
</li>
</ul>
This works in my case.
OR, if that doesn't work, you can try
<ul>
<li *ngFor="let language of languages">
<a [routerLink]="" fragment="{{language}}">{{language}}</a>
</li>
</ul>
<a routerLink="" fragment="section-a">Section A</a>
<a routerLink="" fragment="section-b">Section B</a>
UPDATE 1:
An example at stackblitz:
https://stackblitz.com/edit/angular-routing-section-example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With