我的主要路线是这样的:
export const routes = [
{
path: "",
component: SiteLayoutComponent,
//canActivate: [AuthGuard],
children: [
{ path: "", redirectTo: "/routeA", pathMatch: "full" },
......
......
{
path: 'routeA',
loadChildren: 'app/website/routeA/search/routeA.module#RouteAModule'
}
]
}
];
然后我的routeA
模块路由就像:
const routes: Routes = [
{ path: '', component: SearchComponent,
children:[
{ path: '', pathMatch: 'full', redirectTo: 'featured'},
{ path: 'search', component: FilterResultComponent, outlet: 'searchResult' },
{ path: 'search/:listId', component: DetailsComponent, outlet: 'searchResult' },
{ path: ':listType', component: ListComponent, outlet: 'jobList' }
]
}
];
我的SearchComponent
模板就像:
<search-box></search-box>
<router-outlet name="searchResult"></router-outlet>
<!-- Body Container -->
<div class="container">
<div class="row">
<div class="col-sm-8">
<!-- Job Lists Section -->
<section class="job-list">
<div role="tabpanel" class="custom-tab">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" [class.active]="activeTab === 'featured'" routerLinkActive="" [routerLinkActiveOptions]="{exact: true}">
<a [routerLink]="['featured']" aria-controls="featured" role="tab" data-toggle="tab"><i class="material-icons"></i> Featured Jobs</a>
</li>
<li role="presentation" [class.active]="activeTab === 'female-only'">
<a [routerLink]="['female-only']" aria-controls="female" role="tab" data-toggle="tab"><i class="material-icons"></i> Female Only</a>
</li>
<li role="presentation" [class.active]="activeTab === 'expiring-today'">
<a [routerLink]="['expiring-today']" aria-controls="expiring" role="tab" data-toggle="tab"><i class="material-icons"></i> Expiring Today</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<router-outlet name="jobList"></router-outlet>
</div>
</div>
</section>
<!-- End Lists Section -->
</div
</div>
我想要的是加载routeA
模块作为主路由的默认路由,而routeA
模块内部的特色路由是我的默认路由,它是路由参数而不是:listType
,并且默认情况下会选中featured
标签。
但是当我点击search-box
组件的搜索按钮时,我应该导航到search
路由,并加载filterResultComponent
,我想要做的是:
1-显示ListComponent
路由器插座内的标签内容jobList
,其他组件应位于'searchResult'插座内,我应该隐藏'ListComponent'和标签。
我应该如何使用路由器插座?