Route Parameters in Angular
In Angular, routes can not only be strictly defined, but also support parameters. Thus, we can set a whole group of URLs in one route.
For example, let's say we want the same component to be available at the addresses: aaaa/1
, aaaa/2
, aaaa/3
and so on.
To do this, you need to specify the changing part of the address in the route as a parameter. To do this, you need to write a colon and the name of the parameter. In our case, we will give our parameter the name id
(we can give it any name):
const routes: Routes = [
{ path: 'aaaa/:id', component: AaaaComponent },
{ path: 'bbbb', component: BbbbComponent },
];
Make a route with parameters. Check that the specified component opens for different parameter values.