title: with $location.search(): how to remove a parameter from the url when it's null
body: <p><code>$location.search()</code> to set an url</p>
  
  <p>the search parameter which is passed to the <code>search()</code> is set by a form. selecting and deselecting an element causes some parameters value to be "null" and so the url looks like this : </p>
  
  <pre><code>myapp.com/search?type=text&amp;parameter=null
  </code></pre>
  
  <p>so i would like to remove those "null" parameters from the url. In the documentation, there is a "paramValue" which can be passed as a second parameters to .search(search, paramValue) : <em>If the value is <code>null</code>, the parameter will be deleted.</em></p>
  
  <p>but i can't make this work… any suggestion ? </p>
  
  <p><strong>edit:</strong> here is a solution based on @BKM explanation</p>
  
  <p>to remove every parameters which are <code>null</code>, it's necessary to loop through all of them and test each one, like this : </p>
  
  <pre><code>for (var i in search) {
      if (!search[i]) $location.search(i, null);
  }
  $location.search(search);
  </code></pre>