I have an url pattern to the same location but it ends with different data.
Example:
Keep in mind that "detail" and "object" both are dynamic, example: detail1-category, detail2-category, detail3-category, object1, object2, objectt3.
URL1 = /url/detail-category
URL2 = /url/object
I need to loadChildren based on whether the URL ends with "-category" or not, I am using matcher but I loose the "path" variable since matcher and path can't be used at the same time.
Original:
{ path: 'url/:id',
loadChildren: './modules/child.module#ChildModule'
},
Updated:
{ matcher: categoriesMatcher,
loadChildren: './modules/child.module#ChildModule'
},
export function categoriesMatcher(url: UrlSegment[]) {
return url.length === 1 && url[0].path.endsWith('-category') ? ({consumed: url, path: url}) : null;
}
// the above partially taken from here, and it works but we lose the data which dictates the behavior of the component. Angular 2 different components with same route