title: Angular - Reload HTTP request
body: <p>I am using Angular 5 and have the following problem:</p>
  
  <p>I have a route which contains a parameter year. The related component should now display the data for that year which is retrieved by a service. When first routing to such an URL, this works fine. If I change the parameter year, the component is not reloaded (as expected), just OnInit() is called again. In this method, I try to reload the data by calling the service method with the new year, but it does not work. Here is my code:</p>
  
  <p>test.component.ts:</p>
  
  <pre><code>public ngOnInit() {
      this.route.paramMap.subscribe( params =&gt; {
          if (params.has('year')) {
              this.loadData(params.get('year'));
          } else {
              this.loadData();
          }
      });
  }
  
  public loadData(year?: string): void {
      this.testService.getData(year).subscribe(data =&gt; {
          // edit and set to variables
      });
  }
  </code></pre>
  
  <p>test.service.ts:</p>
  
  <pre><code>public getData(year) {
      return Observable.forkJoin(
          this.getPart1(year),
          this.getPart2(year)
      );
  }
  
  private getPart1(year): Observable&lt;CustomObject[]&gt; {
      let url = this.baseUrl;
      if (year) url = url.concat("?year=" + year);
      return this.http.get&lt;CustomObject[]&gt;(url, httpOptions).pipe(
          catchError(this.handleError&lt;CustomObject[]&gt;())
      )
  }
  
  private getPart2(year): Observable&lt;OtherCustomObject[]&gt; {
      let url = this.baseUrl + '/path';
      if (year) url = url.concat("?year=" + year);
      return this.http.get&lt;OtherCustomObject[]&gt;(url, httpOptions).pipe(
          catchError(this.handleError&lt;OtherCustomObject[]&gt;())
      )
  }
  </code></pre>
  
  <p>How to force the Observable to reload the HTTP request? I tried using a (Replay)Subject instead of Observables, but that didn't work.</p>
  
  <p>Any help is highly appreciated :)</p>