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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With