How to get URL param in last Angular 2 version
<p>I was reading different posts about it but I couldn't found a solution that works on final Angular 2 version.</p>

<p>I load my web app with:</p>

<p><a href="http://127.0.0.1/login?auth=myTokenValue" rel="nofollow noreferrer">http://127.0.0.1/login?auth=myTokenValue</a></p>

<p>I've got in my app.routes.ts</p>

<pre><code>  { path: 'login/:auth', component: LoginComponent },
  { path: '', component: LoginComponent },
  { path: '**', redirectTo: '' }
</code></pre>

<p>and my login.component.ts with:</p>

<pre><code>  ngOnInit() {
    this.sub = this.route.parent.params.subscribe(params =&gt; {
      this.parentRouteId = params["auth"];
      console.log(this.parentRouteId);
    });
</code></pre>

<p>But it always shows on console a</p>

<blockquote>
  <p>undefined</p>
</blockquote>

<p>Note:</p>

<p>I've also tested in app.component.ts this:</p>

<pre><code>ngOnInit() {
    this.sub = this.route.params.subscribe(params =&gt; {
      this.parentRouteId = params["auth"];
      console.log(this.parentRouteId);
    });
  }
</code></pre>

<hr>

<p><strong>RESOLVED:</strong></p>

<p>app.routes.ts</p>

<pre><code>{ path: 'login', component: LoginComponent },
{ path: '', component: LoginComponent }
</code></pre>

<p>login.component.ts</p>

<pre><code>  constructor(private router:Router) {
    var param = router.parseUrl(router.url).queryParams["auth"];
    console.log("Extracted value: ")
    console.log(param);
  }
</code></pre>

<p>I use this url</p>

<pre><code>http://127.0.0.1:4200/#/login?auth=tokenvaluetoread
</code></pre>

<p>on web browser</p>