Reputation:
My console.log from angular 5 service call to component correctly shows the correct data URL
http://localhost:4200/inquiry?UserID=645
However, when it is in the angular for loop in html template it shows
http://localhost:4200/inquiry%3FUserID%3D645
Am the minimum i really need the ?
to be there for my routing
Trying to find URL decoding, how do i accomplish this in component typescript or in template html ngfor loop ? with a pipe ?
Upvotes: 1
Views: 1137
Reputation: 81
via template only:
<div *ngFor="let user of users" routerLink="/inquiry" [queryParams]="{ UserID: user.id }">user.name</div>
template and component:
<div *ngFor="let user of users" (click)="navigateTo(user.id)">user.name</div>
navigateTo(id: number) {
this.router.navigateByUrl('http://localhost:4200/inquiry?UserID='+id);
}
Upvotes: 1