I'm trying to understand how can I limit the options for a param in a route in Angular.
When I'm declaring a route:
{
path: 'food/:name',
component: FoodComponent,
},
:name
can be anything. What I'd like to do is to limit the options to: apple
or orange
, etc..
and if the value is other than the available options - catch it as the 404 route (path: '**'
).
I guess I can always verify the param at the component level, and redirect to 404 if the value isn't match.. but I thought maybe is there is a way to do that at the route level.
Thanks in advance!