- This kinda touches on the distinction between paramMap and params.
- http://www.example.com/somethingerother;foo=13;bar=42;baz=69;qux=86 is an example of a URL with optional parameters and you'll note it is kinda like the usual get variables with the question marks and ampersands replaces by semicolons. (Query parameters have the usual question marks and ampersands per bullet 4 here.) The routerLink example here shows off optional parameters inside of the curly braces. Required parameters in contrast are those which make up URL chunks separated by forward slashes.
- <a [routerLink]="['/meh']" [preserveQueryParams]="true">meh</a> gives an example of preserving the query parameters when the paths change. You need the preserveQueryParams for the trick to work. The queryParamsHandling setting at bullet 8 here may go inline at the a tag I have here as well.
- Read queryParams off of the activatedRoute instance or the snapshot off of the activatedRoute instance as you would just params.
Thursday, November 29, 2018
required, optional, and query parameters in Angular routing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment