Route Parameters in Angular
Route Parameters in Angular: Route Parameters in Angular: an overview, Reading the Route Parameter, Defining the Links.
Updated
- Route Parameters in Angular: an overview (Journeyman): An address can carry a value: /categories/3 means category 3. One route with a parameter, categories/:categoryId, serves every category, like {id} in an ASP.NET Core route. It takes three steps: the route, the component that reads the value, and the links that put it in.
- Reading the Route Parameter (Journeyman): With withComponentInputBinding, the router hands a route's parameters to the page component as inputs, so categoryId is an input like any other, turned into a number with numberAttribute. Load the data in an effect, because Angular reuses the page when only the id changes.
- Defining the Links (Journeyman): Build a link with an id in it by giving routerLink a list of parts: [routerLink]="['/categories', category.categoryId]" makes /categories/3. The same list works with Router's navigate, and the router joins and escapes the parts for you.