TL;DR: How can I tell when the ActivatedRoute has finished parsing the QueryParams, even if there are none?
In my Angular 13 application, I have a need to obtain an optional query parameter before I initialise a service which communicates with the server.
This logic occurs in the root component (because I cannot be sure which page the visitor will land on), so the component is loaded before the routing is initialised. For this reason,
this.route.snapshot.queryParamMap is empty in both the
I know that I can subscribe to the observable returned by
this.route.queryParamMap.subscribe, and this works fine when there are query parameters in the url, however this does not fire if there are no QueryParams available - and due to this, I don't know for sure when the parsing is complete and therefore when to commence connection to the server.
I have tried setting
enabledBlocking but this doesn't seem to help, the queryParams are still not available until some time after the ngAfterViewInit event is called.
My fallback solution is to parse the query string myself, but I don't want to pull in another url parsing library when Angular has a compliant parser built in.