2017-04-27 9 views
4

.NET 코어 용 새 SPA 템플릿을 설치하고 새로운 각도 프로젝트를 만들었습니다. 이동을 원하면 a link입니다. 그것은 라우팅 예제와 함께 제공됩니다. 이제 매개 변수로 작업 할 라우팅을 얻으려고하지만 작동시키기가 어려워졌습니다.매개 변수가 작동하지 않는 각도 라우팅

{ path: '', redirectTo: 'home', pathMatch: 'full' }, 
{ path: 'home', component: HomeComponent }, 
{ path: 'counter', component: CounterComponent }, 
{ path: 'fetch-data', component: FetchDataComponent }, 
{ path: 'fetch-data:id', component: FetchDataComponent }, 
{ path: '**', redirectTo: 'home' } 

을 그리고 이것은 내가 라우터 링크를 정의하고 방법은 다음과 같습니다 : app.module.ts에서

다음과 같이 나는 (매개 변수와 함께) 경로를 정의하고

<a [routerLink]="['/fetch-data',3]"> 
    <span class='glyphicon glyphicon-th-list'></span> Fetch data by ID 
</a> 

링크를 가리키면 경로가 올바르게 표시되지만 클릭하면 집으로 돌아갑니다.

{ path: 'fetch-data', component: FetchDataComponent }, 

답변

3

변경

{ path: 'fetch-data:id', component: FetchDataComponent },

{ path: 'fetch-data/:id', component: FetchDataComponent }, 
+0

사람 : 나는 내가 다음 줄을 삭제 위는 경로와 충돌,하지만 여전히 작동하지 않습니다 어쩌면 생각 그 덕분에, 고마워! –