0

I am new to Angular 2. I was going through this link , which mentions different ways of writing route links.

1. <a [routerLink]="[ '/path', routeParam ]">
2. <a [routerLink]="[ '/path', { matrixParam: 'value' } ]">
3. <a [routerLink]="[ '/path' ]" [queryParams]="{ page: 1 }">
4. <a [routerLink]="[ '/path' ]" fragment="anchor">

I am only aware of the 1st type of route , can anyone explain about the other three

refactor
  • 13,954
  • 24
  • 68
  • 103

1 Answers1

2

1) The first is part of the path. This are route parameters

{ path: '/path/:someParam', ...

3) are query parameters that are added after the path (see also https://en.wikipedia.org/wiki/Query_string)

/path/xxx?queryParam=value

2) are matrix parameters and similar to 3) but query parameters can only be used at top-level routes and matrix parameters 2) can only be used on child routes

/path/child/;page=1/otherchild?queryParam=value

4) Is the HTML fragment identifier part

/path/xxx?queryParam=value#anchor

which makes the browser scroll to an <a name="anchor"> or an element with the id anchor <header id="anchor">. (The fragment identifier is only processed by the client (browser) and never sent to the server)

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567