title: How to create/update a ParamMap in Angular 5?
body: <p>In Angular 5, the Router/ParamMap object is immutable. It can be retrieved from the route and used in a component. However, I have a use case for which modifying the ParamMap would be convenient (and it worked fine with Angular 4).</p>
  
  <p>Previously, I used the <code>convertToParamMap</code> function to convert an <code>Object</code> to a <code>ParamMap</code>. Since updating to Angular 5, the resulting <code>ParamMap</code> object's private <code>params</code> member loses its prototype and generates an error when I call the resulting <code>ParamMap</code>'s <code>.get(key)</code> method.</p>
  
  <pre class="lang-js prettyprint-override"><code>const params = this.routeParams.keys.reduce(
      (pv: Params, cv) =&gt; {
          pv[cv] = this.routeParams.get(cv); // &lt;- Error on second call
          return pv;
      },
      Object.create(null) as Params
  );
  params["changedKey"] = newValue;
  this.routeParams= convertToParamMap(params);
  </code></pre>
  
  <p><code>this.routeParams</code> is initially populated from a call to the <code>ActivatedRoute</code> instance's <code>queryParamMap</code> method and simply setting my component's <code>routeParams</code> member to the returned <code>ParamMap</code> instance.</p>
  
  <p>On my first pass through the code above, everything works fine. On the second pass, after I've updated the <code>routeParams</code> member with the <code>convertToParamMap</code> function, I receive this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Object doesn't support property or method 'hasOwnProperty'
  </code></pre>
  
  <p>Via the debugger, the <code>.get(cv)</code> call is internally calling the <code>.has(cv)</code> method, which then calls <code>this.params.hasOwnProperty(name)</code> <em>(<code>this</code> = the <code>ParamMap</code> object and <code>name</code> = <code>cv</code>)</em>. I'm thinking this is a bug in Angular 5, but I'm looking for an alternative or workaround until it gets fixed.</p>
  
  <p>Any suggestions?</p>