title: How to handle multiple queryParams in Angular2
body: <p>I'm trying to implement a filtering mechanism in a new Angular2 app, that would allow me to filter a list of entries in an array. The entries may have around 20 properties that could be filtered on. I have so far created a list of filters in one component and then a list component that is routed to, as a child.
  I then planned to pass the filters as queryParams through the router. Starting with just one filter this was fine:</p>
  
  <p>On the send side I had:</p>
  
  <pre><code>this.router.navigate(['/findlist'], {queryParams: {'g': myParam}});
  </code></pre>
  
  <p>The on the receive side, I had:</p>
  
  <pre><code>this.subscription = this.route.queryParams.subscribe(
    (queryParam: any) =&gt; this.myFilter = queryParam['g']
  );
  </code></pre>
  
  <p>I then pass myFilter to a filter pipe to do the match and filter. All OK so far.</p>
  
  <p>However, I can't figure out how to scale this up to allow for multiple potential Params, most of which would be blank/not needed. </p>
  
  <p>I can imagine that I would need to define an array holding ALL of the active filters through the queryParam, but the only documentation I can find, only ever shows examples with just one parameter passed. I've tried playing around with:</p>
  
  <pre><code>{queryParams: { pass an array here! }}
  </code></pre>
  
  <p>But my IDE registers an error if I put anything in other than a key:value pair.</p>
  
  <p>I could probably just add in all the possible filters and their values each time, but that would create a URL string stupidly long each time, with most values blank or All etc., not very pretty.</p>
  
  <p>So I think my workflow should be that on the send side I maintain an array of all the filters and their states and then each time one of the filter buttons is clicked, I first update the relevant value in the array and then pass the whole array through queryParams. </p>
  
  <p>On the receive side somehow I have to receive and process the Param as an array and then extract each entry as variables to then process in the filter. I also want to be DRY, so don't really want several statements on the receive side effectively doing the same thing for different properties, simplistically it makes more sense to cycle through an array instead.</p>
  
  <p>I hope that makes sense, I'd be grateful if anyone has a suggestion, even if it means passing the data in a different way. For example, I'm currently now looking to see whether I can just pass the data by creating a separate filter service and passing it using @Input instead.</p>
  
  <p>Any ideas gratefully received
  (self taught amateur so probably missing something obvious !)</p>
  
  <p>Thanks</p>
  
  <p>Tony</p>