Based on the parent path /search, would like to resolve [NavigActionResolve] and activate child routes as below.
path:'search',
component:SpaceComponent,
resolve: {
navigAction: NavigActionResolve
},
children: [
{
path:'',
component:SpaceProviderFiltersComponent,
canActivate: [ShowProviderFiltersRouteGuard],
outlet:'provider-filters'
},
{
path:'',
component:SpaceConsumerFiltersComponent,
canActivate: [ShowConsumerFiltersRouteGuard],
outlet:'consumer-filters'
}
]
As I need to use both child outlets, I set the path as
path:''
so that both are picked by default. However, based on the conditions set in my guards, I want only one of these outlets to be active.
Guards [de]activate as below
ShowProviderFiltersRouteGuard
canActivate() {
return Promise.resolve(this.componentStateService.isShowProviderFilters());
}
ShowConsumerFiltersRouteGuard
canActivate() {
return Promise.resolve(!this.componentStateService.isShowProviderFilters());
}
Please note NOT [!] in above ShowConsumerFiltersRouteGuard related canActivate(). Hence, only one should be active at any point of time.
Below is how I used these outlets in my Html
<div class="mdl-cell mdl-cell--12-col columns">
<router-outlet name="provider-filters"></router-outlet>
<router-outlet name="consumer-filters"></router-outlet>
</div>
What I noticed is, as both child paths are same, both are deactivated and my routes are cancelled. My requirement is, I can't have separate paths for each and am wondering how I could make this work. Any advise please.