2016-08-18 10 views
0

ルーティングにおけるルーティング、 enter image description here角度2(RC-5)を用いて、ルーティングにおけるルーティング行う方法角度2

app.html

<nav> 
    <a routerLink="/developers" routerLinkActive="active">Developers</a> 
    <a routerLink="/customers" routerLinkActive="active">Customers</a> 
</nav> 
<div class="container"> 
    <div class="row"> 
    <router-outlet></router-outlet> 
    </div> 

とdeveloper.html
***この2つのリンク(リンク1とリンク2)をメインにリダイレクトすること*コード**

<a routerLink="/link1">link1</a> 
<a routerLink="/link2" routerLinkActive="active">link2</a> 
<router-outlet></router-outlet> 

問題あなたが持っているoutleet

答えて

0

ルータは//developer.html

<a routerLink="/link1">link1</a> 
<a routerLink="/link2" routerLinkActive="active">link2</a> 
<router-outlet name="auxPathName"></router-outlet> 

とルーティング構成で

auxPathName

が含まれ、第2ノードルータコンセントに別の名前を与えるためにルータ出口ノードを複数追加する方法を説明します。ここではhttps://stackoverflow.com/a/34642273/896258


のみ(Angular2 RC5、ルータ3-RC1)1つのルータ出口ノード私の実施例です。

HTMLファイル

<ul> 
    <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact: true}"><a routerLink="events">All Events</a></li> 
    <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact: true}"><a routerLink="events/news">News</a></li> 
    <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact: true}"><a routerLink="events/family">Family Events</a></li> 
    <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact: true}"><a routerLink="events/wedding">Wedding Events</a></li> 
    </ul> 
</div> 

app.routingファイル

import { Routes, RouterModule } from '@angular/router'; 

import { EventsComponent } from './events/events.component'; 
import { EventDetailsComponent } from './eventdetails/eventdetails.component'; 

const appRoutes: Routes = [ 
    { path: 'events', component: EventsComponent }, 
    { path: 'events/:type', component: EventsComponent }, 
    { path: 'events/:id/detail', component: EventDetailsComponent }, 
    { path: '', redirectTo: 'events', pathMatch: 'full' }, 
    // { path: '**', component: PageNotFoundComponent }//TODO: this should redirect to PageNotFound 
]; 

export const appRoutingProviders: any[] = []; 

export const routing = RouterModule.forRoot(appRoutes); 
関連する問題