1

我的主要路由是这样的:

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">&#xE885;</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">&#xE87C;</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">&#xE01B;</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”和选项卡。我应该如何用路由器插座做到这一点?

4

0 回答 0