I have a question regarding using Angular (4) with the @angular/router. I want to be able to include optional parameters in a path style, but am facing some challenges.
Currently, my code looks like this:
{ path: 'cars', component: CarComponent },
{ path: 'cars/:type', component: CarComponent },
{ path: 'cars/:type/:brand', component: CarComponent },
{ path: 'cars/:type/:brand/:id', component: CarComponent },
While this setup works, I am specifically looking to make the parameter :type optional. It should either be set to 'new' or left empty, and it is this empty part that is proving to be challenging as Angular struggles to determine the context.
Any assistance on resolving this issue would be greatly appreciated.