I'm doing my project in Angular 8 and face the problem with passing data using routerLink
here is my <tr>
with routerLink
<tr *ngFor="let user of allData" [routerLink]="['client', user.clientId]">
ClientComponents and my idea for passing data
public clientData: any = this.route.params.subscribe(params => {
return params.clientId;
});
then I'm passing that data to ClientService
getMethodClientDetails(): void {
this.clientsService.getClientsDetails(this.clientData)
.subscribe(data => {
this.list = data;
},
error => this.errorMsg = error,
);
}
and my clientService function looks like:
getClientsDetails(data): Observable<any> {
return this.http.get<any>(URL + data)
.catch(this.errorHandler);
}
and this is my Request URL
/clients?clientId=[object%20Object]
instead of clientId I get an error. I don't know what's the issue, I'm passing just one value, not whole object
When I'm doing just console.log to check- everything looks correctly.
public clientData: any = this.route.params.subscribe(params => {
console.log(params.clientId);
});
output in console
16960
Could someone help me solve that problem?