title: Handling Dynamic URL Params via RouterLink in Angular App
body: <p>In my Angular 2 app I have a tab area where users can select from a group of independent, but contextually related components. When they click on one of these links, the relevant component loads according to what's defined in the routerLink, like this:</p>
  
  <pre><code>&lt;a class="page-content-header-item" routerLink="/page1" routerLinkActive="selected"&gt;Page 1&lt;/a&gt;
  </code></pre>
  
  <p>This was working well. However, since then we've built the app to save various user-selected filter selections as params in the URL. This way when they re-load the component, they'll have their most recent selections still visible and applied to the data. So the URL might look like this after the user had made some filter selections:</p>
  
  <pre><code>http://somesite.com/page1;language_filter=true;language_selection=English
  </code></pre>
  
  <p>The component code for this looks like this:</p>
  
  <pre><code>public changePage(page, value, type, body)
  {
      this.onUserSelection(value, type, body, page);
  
      this.route.params.subscribe(
          (params: any) =&gt; {
              this.page = params['page'];
              this.language_filter = params['language_filter'];
              this.language_selection = params['language_selection'];
          }
      );
      this.router.navigate(
          ['/page1', {
              page: page,
              language_filter: this.language_filter,
              language_selection: this.language_selection,
          }]);
  }
  </code></pre>
  
  <p>This works well for the main navigation methods, that are accomplished via a routing file, where each one looks like this:</p>
  
  <pre><code>{ path: 'page1', component: Page1Component, canActivate: [AuthGuard], data: {contentId: 'page1'} }
  </code></pre>
  
  <p>However, for this tab area I mentioned, it's loading components according to a hard-coded routerLink param. So I realize now that when a user navigates BACK to a component that way, as opposed to via one of the other ways we make available, it actually overrides the URL params - because it's literally loading "page1" -- because of this <code>&lt;a class="page-content-header-item" routerLink="/page1" routerLinkActive="selected"&gt;Page 1&lt;/a&gt;</code></p>
  
  <p>... and thus the URL params that had been added previously are wiped out. </p>
  
  <p>So, my question is, is there a way I can edit this code:</p>
  
  <pre><code>&lt;a class="page-content-header-item" routerLink="/page1" routerLinkActive="selected"&gt;Page 1&lt;/a&gt;
  </code></pre>
  
  <p>... so it allows for some dynamic variables? Or do I have to find a new way to handle the navigation in this tab area?</p>