angular read query params from url code example
Example 1: angular http request query params
request(query) {
let params = new HttpParams().set("keyword", query);
return this.http.get(`Your_URL`, {params});
}
Example 2: angular set query params
constructor(private router: Router) { }
public myMethodChangingQueryParams() {
const queryParams: Params = { myParam: 'myNewValue' };
this.router.navigate(
[],
{
relativeTo: activatedRoute,
queryParams: queryParams,
queryParamsHandling: 'merge', // remove to replace all query params by provided
});
}