I'm trying to use a regex on the parent route and then also have child routes, so I tried this:
const barcodeRoute = () => (segments: UrlSegment[]) => {
if (!segments.length)
return null
const segment = segments[0]
return barcodeRegex.test(segment.path) ? {consumed: [segment], posParams: {barcode: segment}} : null
}
export const routes: Routes = [
{
component: DisplayRootComponent,
matcher: barcodeRoute(),
children: [
{
path: 'safety-assessment',
loadComponent: () => import('./app/safety-assessment/safety-assessment/safety-assessment.component')
.then(x => x.SafetyAssessmentComponent)
}
]
}
]
The regex will match and display the DisplayRootComponent
, but if I append /safety-assessment
to the end of the route, it still goes to the DisplayRootComponent
instead of SafetyAssessmentComponent
.
All the other posts I've seen on this are solved by "consuming" part of the url segments, which I've done, so I'm not sure what I'm missing.
A very simplified example without matchers or lazy loading can be see at this StackBlitz.