title: Angular2 get url query parameters
body: <p>I'm setting up a Facebook registration for my Angular2 web app.
  Once the application accepted via Facebook (after being redirected to the Facebook authorization page), it redirect to my webapp with the token and code as url params:</p>
  
  <pre><code>http://localhost:55976/?#access_token=MY_ACCESS_TOKEN&amp;code=MY_CODE
  </code></pre>
  
  <p>But once the page is loaded, the params are removed. The url become:</p>
  
  <pre><code>http://localhost:55976/
  </code></pre>
  
  <p>How can I extract the parameters (access_token and code) before they are removed?
  My routing configuration contains:</p>
  
  <pre><code>{ path: 'login', component: LoginComponent },
  { path: 'login/:access_token/:code', component: LoginComponent },
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is how I redirect to facebook in my login.component:
  html:</p>
  
  <pre><code>&lt;a class="btn btn-social btn-facebook socialaccount_provider facebook" title="Facebook" href="#" (click)="login_facebook()"&gt;
      &lt;span class="fa fa-facebook"&gt;&lt;/span&gt; &lt;span style="padding-left:25px"&gt;Sign in with Facebook&lt;/span&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>Typescript:</p>
  
  <pre><code>login_facebook() {
      let url = 'https://www.facebook.com/dialog/oauth?'+
          'client_id=my_client_id' +
          '&amp;redirect_uri=' + encodeURIComponent('http://localhost:55976/#/login/') +
          '&amp;response_type=code%20token';
      console.log(url);
      window.location.href = url;
  }
  </code></pre>
  
  <p>The facebook api redirect to <a href="http://localhost:55976/#/login/" rel="noreferrer">http://localhost:55976/#/login/</a>, this is where I try to get the access_token and code parameters.</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>If I remove the sharp in the redirect url, facebook redirect me to the good URL, but without the sharp, angular cannot resolve the url.</p>
  
  <p>Before removing '#':</p>
  
  <pre><code>redirect_uri: http://localhost:55976/#/login/
  facebook return: http://localhost:55976/?#access_token=MY_ACCESS_TOKEN&amp;code=MY_CODE
  </code></pre>
  
  <p>After removing '#':</p>
  
  <pre><code>redirect_uri: http://localhost:55976/login/
  facebook return: http://localhost:55976/login/?#access_token=MY_ACCESS_TOKEN&amp;code=MY_CODE
  </code></pre>
  
  <p>That mean that the problem comes from the sharp. But without the sharp, angular returns HTTP Error 404.0 - Not Found.</p>