I am trying to pass a string using this code:
this.router.navigate(['/systems', params.toString()]);
The route parameter is then added to the URL to call the API.
params.toString()- change_user=2258. When it is sent through the browser, it changes to change_user%3D2558in the URL. When I use the developer tools to see what was sent to the API, it was changed to NaN.
How to pass a string through a router so that I can directly add it to the API string?
Edit: the variable paramsis of type URLSearchParams(). This is how I try to extract the parameter:
this.route.paramMap.switchMap((params: ParamMap) =>
this.httpService.getSites(+params.get('params')))
.subscribe(sites => this.sites = sites);
ecain source
share