Reputation: 799
I need to load different components based on the type of route parameter. if the route parameters is string then load one component like below,
{ path: 'care/action/:string',component: StringComponent},
if the route parameters is number then load another component like below
{ path: 'care/action/:number', component: NumberComponent},
Please note that URL will remain same, only type of parameter will change.
How to achieve this?
Thanks in advance.
Upvotes: 5
Views: 1871
Reputation: 15291
You might want to leverage matcher property on your route configs and pass a matching function to it. Your matcher function would use regular expression to check if its a string (for string route) or number (for number).
Upvotes: 1