I don't know if there is another way to do this, but I managed to get it to work using the following hack.
export const productsRoutes: Route[] = [ { path: 'products', component: ProductsComponent, children: [ { path: '', pathMatch: 'prefix', component: ProductsListComponent, children: [ { path: '', component: EmptyComponent, }, { path: ':category', component: EmptyComponent, }, ], }, ], }, ];
EmptyComponent:
import { Component } from '@angular/core'; @Component({ selector: 'GemainEmpty', template: '<router-outlet></router-outlet>', }) export class EmptyComponent { }
Process route changes in ListComponent:
ngOnInit() { this.routerEventsSubscription = this.router.events.subscribe((evt) => { if (!(evt instanceof NavigationEnd)) { return; } //Code to reload/filter list } }
And add the router socket to the ListComponent template.
source share