Is there an automated way I can get ALL of the querystrings in the address bar without knowing what the names are?
For instance I want to get all of the following:
reports?api=Report1&from=&to=&agentId=2&status=1&fixtureId=3&gradeId=4
I've had a look everywhere but I can only see examples where you can only get if it you know the name.
I'm not sure if answer should be somehow related to angular but a simple solution would be:
location.search - gets query string with all params
https://www.npmjs.com/package/query-string - nice package which converts queryString to params object for your convenience.
ImportActivatedRoute
import { ActivatedRoute } from "@angular/router";
And initialize on constructor
constructor(private activatedRoute: ActivatedRoute) {
}
Then use this below code to getting query string
this.activatedRoute.params.subscribe(params => {
let from = params['from'];
});
this this.activatedRoute.params having all query strings . but if you want get the value then you should go with subscribe. or get the whole url and need to use split(); the URL to get query strings.