0

The Angular Router documentation mentions that we can use fragment parameters with the RouterLink directive, but how do we do this? For example:

 <a routerLink="/crisis-center" [fragment]="ufoinvasion">

And then specify a crises with a ufoinvasion id in the crisis center?

Ole
  • 41,793
  • 59
  • 191
  • 359
  • Have you read this https://stackoverflow.com/questions/37880876/how-to-pass-query-parameters-with-a-routerlink-in-the-new-router-v-3-alpha-vlad ? – Ignacio Ara May 08 '18 at 13:43
  • Fragements and query parameters are two different concepts IIUC ...? – Ole May 08 '18 at 14:02
  • Read the validated answer, it includes an example with fragments – Ignacio Ara May 08 '18 at 14:03
  • OK I see the fragment syntax now. Lets assume that the example navigates to `heroes`, and the fragment points to `yyy` which is the ID of the element containing a hero, will the specification of the fragment identifier now cause Angular to scroll the browser to the hero location. In other words the URL ends up being /heros#yyy ...? – Ole May 08 '18 at 14:13
  • 1
    I assume that the code `fragment: 'anchor'` indicates it will be an anchor like #yyy as you said. In the Angular example it also adds the tag `` – Ignacio Ara May 08 '18 at 14:20

0 Answers0