liveBook · Manning

URL matrix notation

As explained in Pro Angular 16

URL matrix notation is a URL convention that represents optional parameter values as semicolon-separated name-value pairs within a path segment.

URL matrix notation places optional route parameters inside a path segment as semicolon-separated name-value pairs. These values can guide a component without being essential to route activation. The convention is outside the URL specification, although browsers support it. section 24.3.2

Use matrix parameters when a route can continue without the supplied values:

  • Generate parameters as literal properties, such as name, category, and price. section 24.3.2
  • Read them like required route parameters and let the component check whether each value exists. section 24.3.2
  • Use present values to override repository data while retaining fallback values when parameters are absent. section 24.3.2

Editing a product with optional values

A generated route such as /form/edit/2;name=Lifejacket;price=48.95 can populate the edit form without relying entirely on a repository request. A fuller example adds category=Soccer, producing /form/edit/5;name=Stadium;category=Soccer;price=79500. section 24.3.2

Listing 24.16. An optional route parameter in the table.component.html file in the src/app/core folder
...
<button class="btn btn-warning btn-sm"
        (click)="editProduct(item.id)"
        [routerLink]="['/form', 'edit', item.id,
            {name: item.name, category: item.category, 
                price: item.price}]">                
    Edit
</button>
...

See the Angular routerLink listing that constructs matrix parameters from product properties. section 24.3.2

How Pro Angular 16 covers it

How deep it goes
Explains syntax, generation, retrieval, fallback handling, and repository overrides, but defers route activation guards.
Examples
Demonstrates product-edit URLs carrying name, category, and price values separated by semicolons.
What it assumes
Assumes route-parameter handling and component-based forms, while showing optional-value checks from the routing example.
What you can do after
Apply it via Angular routerLink and component inputs to provide optional values and preserve repository fallbacks.
How it connects
Connects optional route parameters with route parameters, Angular routing, components, repositories, and form population.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.