0
list-profile html doc 내에 제공된 링크를 한 번 눌러 변수를 보내려고합니다. 현재 코드가 작동하지 않고 충돌합니다. 필요한 경우 자세한 내용을 제공 할 수 있습니다.routerLink를 통해 새 구성 요소에 매개 변수를 전달하십시오.
리스트 profile.component.html
<div class="col col-sm-4 col-sm-offset-4">
<ul id="list_of_users">
<li class="list-group-item list-group-item-action" *ngFor="let user of users"><a [routerLink]="['/profile', user.id]" routerLinkActive="active" (click)="testFunc(user.id)">{{user.name}}</a></li>
</ul>
</div>
app.module.ts
const appRoutes: Routes = [
{ path: 'addProfile', component: AddProfileComponent },
{ path: 'listProfiles', component: ListProfilesComponent},
{ path: 'profile:id', component: ProfileComponent}
];
그것은 더 이상 충돌하지 않습니다! 그러나 변수를 가져올 위치는 어디입니까? 생성자 내부에? – Amar
내부 생성자 또는 ngOnInit –
코드 예제를 제공 할 수 있습니까? 때문에 atm 구성 요소 : Class 'ProfileComponent'잘못 인터페이스 'OnInit'구현합니다. 속성 'ngOnInit'의 유형은 적용 할 수 없습니다. '(id : string) =>'void '유형을'() => void 유형으로 지정할 수 없습니다. – Amar