title: Angular get query param and call service
body: <p>I've got a problem in my angular app. I have to call a service reading some params from url. It's not working because the service is fired before the subscription to have the params is finished. In my service file I have this:</p>
  <pre><code>constructor(private http: HttpClient, private route: ActivatedRoute) { 
      this.route.queryParams.subscribe(params =&gt; {
        this.param1 = params['param1'];
        this.param2 = params['param2'];
      });
    }
  </code></pre>
  <p>and then the service:</p>
  <pre><code>getConfigs() {
      let configPath = baseUrl + this.param1 + &quot;/&quot; + this.param2;
      return this.http.get&lt;any&gt;(configPath);
    }
  </code></pre>
  <p>so, in my <code>AppComponent</code> I call the <code>getConfigs()</code> service but it's not working because the two params are undefined. How can I fix it? That's how I call the service in <code>AppComponent</code></p>
  <pre><code>this.service.getConfigs().subscribe((configData) =&gt; {
        this.configParams = configData;
      });
  </code></pre>