angular get with params 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 get url params
import { ActivatedRoute } from "@angular/router";
private $route: ActivatedRoute
this.$route.params.forEach(param =>
this.myvar = param['whatever your param name is']
);
Example 3: get route query params angular
export class HeroComponent implements OnInit {
constructor(private _activatedRoute: ActivatedRoute, private _router:Router) {
_router.routerState.queryParams.subscribe(
params => console.log('queryParams', params['st']));