From what I understand from the documentation for the Angular2 router, the default config config route strategy is “prefix”. The “prefix” pathMatch strategy means that the application router only needs to look at the beginning of the URL and map it to the corresponding route.
Link: https://angular.io/docs/js/latest/api/router/index/Routes-type-alias.html#!#matching-strategy
It was said that with the configurations below, I would suggest that this route should load ExampleComponent if I go to /abcdefg .
One problem: this does not work , I'm not sure what is wrong, and I can not find much information about this in google or in the @angular/router source code.
Thank you for your help.
const ROUTES: Routes = [ { path: '', component: MainLayoutComponent, pathMatch: 'prefix', canActivate: [AuthGuard], children: [ { path:'abc', pathMatch: 'prefix', component: ExampleComponent}, { path: '', component: HomepageComponent } ]}, ]; export const ROUTING = RouterModule.forRoot(ROUTES, { useHash: false });
Update # 1, an attempt by Günter Zöchbauer.
new router configurations:
now /abc/defg works, but not /abcdefg
{ path:'abc', pathMatch: 'prefix', children: [ { path:'**', component:ExampleComponent}, ] }