2017-02-24 86 views
1

我有用於路由router.navigate不改變輔助路線

export class WetterRoutingService { 

    private currentUser: User; 
    private defaultAbm: Abm; 
    public rerouteToDefaultOnLoad: boolean = false; 
    constructor (@Inject(UserService) private userService: UserService, 
    @Inject(UiDataStore) private uiDataStore: UiDataStore, private router: Router) { 
     // get User Data and relevant data 
} 

我提出在此服務的功能來路由到某些路線我經常使用(鏈接動態地改變根據用戶的服務和數據)

public routeToAbmAuxMaps(id) { 
    this.router.navigate([ '/start', DATA_CONSTANTS.some_constant, id, {outlets: { aux: ['maps']}}]); 
} 

我定義了以下路線:

export const ROUTES: Routes = [ 

    { 
    path: '', 
    redirectTo: '**', 
    pathMatch: 'full' 
    }, 

    { 
    path: 'start/:type/:abm', 
    component: AbmBlock, 
    canActivate: [UserService], 
    resolve: { 
     model: AbmBlockResolver 
    }, 
    }, 
    // some other routes 
    { 
    path: 'maps', 
    component: MapsDetailBlock, 
    outlet: 'aux' 
    }, 
    { 
    path: '**', 
    component: AbmBlock, 
    resolve: { 
     data: AbmBlockResolver 
    }, 
    } 
]; 

和我的路由器,網點在app.html

 <div class="main-container" id="main-container"> 
      <div class="main-panel"> 
       <router-outlet (activate)="onMainActivate($event)"></router-outlet> 
      </div> 
     </div> 
     <div class="detail-container" id="detail-container"> 
      <div class="detail-panel"> 
       <router-outlet name="aux" (activate)="onDetailActivate($event)"></router-outlet> 
      </div> 
     </div> 

時,此功能被稱爲然而,路由器解析爲

BaseUrl/#/start/constant/id 

我所期待的是

BaseUrl/#/start/constant/id(aux:maps) 

這是一個錯誤,我應該張貼在GitHub上這還是我做錯了什麼?

角2.4.3 TS 2.1.5

E:格式化

回答

1

您應該將outlets對象改成這樣:(aux不是數組)

{outlets: { aux: 'maps'}} 
+0

我改變了通話到 this.router.navigate(['/ start',DATA_CONSTANTS.abm,abmId,{outlets:{aux:'maps'}}]); 它仍然做同樣的事情 – user3548538